Javascript 复选框ng型号值不根据复选框更改/更新单击
我有以下复选框:-Javascript 复选框ng型号值不根据复选框更改/更新单击,javascript,.net,angularjs,checkbox,Javascript,.net,Angularjs,Checkbox,我有以下复选框:- <input type="checkbox" ng-click="toggleShowOtherUserConfiguration()" ng-model="showOtherUserConfiguration" name="ShowOtherUserConfiguration" value="showOtherUserConfiguration" /> 这样,当页面加载时,复选框将始终保持false 但实际情况是:-
<input type="checkbox" ng-click="toggleShowOtherUserConfiguration()"
ng-model="showOtherUserConfiguration"
name="ShowOtherUserConfiguration"
value="showOtherUserConfiguration" />
这样,当页面加载时,复选框将始终保持false
但实际情况是:-
当页面加载时,复选框保持未选中状态,此时,$scope.showOtherUserConfiguration
值为false
选中复选框时,其值保持为false
当复选框状态从选中更改为未选中时,
$scope.showOtherUserConfiguration
值变为true
请指导我如何才能$scope.showOtherUserConfiguration
在未选中时保持false
,在选中时保持true
注意:-除了更改
$scope之外,不更改切换showOtherUserConfiguration()
函数中的任何内容。showOtherUserConfiguration
值您不能使用ng单击
复选框,您需要使用ng更改
来处理复选框事件
试试这个:
var-app=angular.module('app',[]);
app.controller('OneController',函数($scope){
$scope.showOtherUserConfiguration=false;
$scope.toggleShowOtherUserConfiguration=函数(参数){
log($scope.showOtherUserConfiguration);
}
});
{{showOtherUserConfiguration}}
您不能使用ng单击带有复选框的
,您需要对复选框事件使用ng更改
试试这个:
var-app=angular.module('app',[]);
app.controller('OneController',函数($scope){
$scope.showOtherUserConfiguration=false;
$scope.toggleShowOtherUserConfiguration=函数(参数){
log($scope.showOtherUserConfiguration);
}
});
{{showOtherUserConfiguration}}
$scope.showOtherUserConfiguration = false;