0
这里是我的单选按钮的代码Angularjs:检查单选框自动
<input type="radio" ng-model="choice.phone" ng-value="1" name="phone" ng-
click="setPhoneType('cell')"> cell phone<br/>
<input type="radio" ng-model="choice.phone" ng-value="2" name="phone" ng-
click="setPhoneType('Home')"> Home phone <br/>
现在,当用户选择其中的任何然后在下面的单选按钮应作为托运默认
<input type="radio" ng-model="choice.International" ng-value="1"
name="international" ng-click="setChoiceType('Inter')" ng-checked="choice.phone"> International call
JS代码是如下:
setPhoneType = function setPhoneType(phoneType) {
$scope.phone = phoneType;
$scope.setChoiceType('Inter');
return;
},
setChoiceType = function setChoiceType(callType) {
$scope.international = callType;
return;
},
的问题是,当我选择任何phone
那么Inter
被自动检查,但后来的值是未定义的,它会去setChoiceType
,但之后choice.International是未定义的。如果我手动选择Inter (by clicking on it)
这很好。
一个小提琴或plunkr会使它更容易帮助。 – dnc253