angular.js - angularjs如何默认选中radio
PHP中文网
PHP中文网 2017-05-15 16:55:10
0
6
1351
<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>

angularjs如何默认选中第一个

PHP中文网
PHP中文网

认证0级讲师

reply all(6)
为情所困

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>
仅有的幸福

Set the value of

institution.display to the corresponding

某草草

checked = "checked"

过去多啦不再A梦
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>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template