I work on my angularjs project I use bootstrap3 .
我使用bootstrap3处理我的angularjs项目。
I have those radio buttons:
我有那些单选按钮:
<label class="radio-inline"><input type="radio" name="optradio" ng-click="toSeachBySiteNumber = false; list.filterArguments.siteDescription=null" selected>sites</label>
<label class="radio-inline"><input type="radio" name="optradio" ng-click="toSeachBySiteNumber = true; list.filterArguments.siteDescription=null">regions</label>
After page loaded I need by default sites radio button to be selected.
页面加载后,我需要默认选择站点单选按钮。
How can I implement it?
我该如何实现它?
2 个解决方案
#1
1
You should use checked attribute instead of selected attribute on sites radio button.
您应该在站点单选按钮上使用checked属性而不是selected属性。
<label class="radio-inline"><input type="radio" name="optradio" ng-click="toSeachBySiteNumber = false; list.filterArguments.siteDescription=null" checked='checked'>sites</label>
<label class="radio-inline"><input type="radio" name="optradio" ng-click="toSeachBySiteNumber = true; list.filterArguments.siteDescription=null">regions</label>
JS Fiddle example.
JS小提琴的例子。
#2
0
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<label class="radio-inline"><input type="radio" name="optradio" ng-click="toSeachBySiteNumber = false; list.filterArguments.siteDescription=null" ng-model="modelVar" ng-init="modelVar=true" ng-value="true">sites</label>
<label class="radio-inline"><input type="radio" name="optradio" ng-click="toSeachBySiteNumber = true; list.filterArguments.siteDescription=null">regions</label>
use ng-value="true"
#1
1
You should use checked attribute instead of selected attribute on sites radio button.
您应该在站点单选按钮上使用checked属性而不是selected属性。
<label class="radio-inline"><input type="radio" name="optradio" ng-click="toSeachBySiteNumber = false; list.filterArguments.siteDescription=null" checked='checked'>sites</label>
<label class="radio-inline"><input type="radio" name="optradio" ng-click="toSeachBySiteNumber = true; list.filterArguments.siteDescription=null">regions</label>
JS Fiddle example.
JS小提琴的例子。
#2
0
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<label class="radio-inline"><input type="radio" name="optradio" ng-click="toSeachBySiteNumber = false; list.filterArguments.siteDescription=null" ng-model="modelVar" ng-init="modelVar=true" ng-value="true">sites</label>
<label class="radio-inline"><input type="radio" name="optradio" ng-click="toSeachBySiteNumber = true; list.filterArguments.siteDescription=null">regions</label>
use ng-value="true"