<label class="radio-inline">
<input name="display" type="radio" value="true" ng-model="institution.display" checked required>顯示
</label>
<label class="radio-inline">
<input name="display" type="radio" value="false" ng-model="institution.display">隱藏</label>
How to select the first one by default in angularjs
認證0級講師
Just use ng-checked
.
<label class="radio-inline">
<input name="display" type="radio" value="true" ng-model="institution.display" ng-checked="true" required>
顯示
</label>
<label class="radio-inline">
<input name="display" type="radio" value="false" ng-model="institution.display">
隱藏
</label>
ng-checked
Just add the ng-model binding element at the same time
Two-way binding
Two-way binding
Two-way binding
It’s important to say it three times~~~
$scope.institution.display = "true";
That is, ng-model and value can be the same.
can be found in ng-repeat
中使用 ng-checked
, in the form:
<label ng-repeat="(key, val) in genders track by $index">
<input type="radio" name="gender" value="{{key}}" ng-checked="list.gender==key">{{val}}
</label>