我正在使用复选框
<input type="checkbox" value="{{areaFilter.area_name | lowercase}}" ng-checked="true" />
我想保持复选框已经选中或取消选中,而页面加载依赖于某个值(selectedArea): 像
if(selectedArea.indexOf(areaFilter.area_name) > -1)
然后
ng-clicked="true"
否则
ng-clicked="false"
如何在HTML页面中执行此操作。
请指导。
答案 0 :(得分:0)
它可能对你有所帮助!!
<!DOCTYPE html>
<html ng-app="plunker">
<head>
<meta charset="utf-8" />
<script data-require="angular.js@1.3.x" src="https://code.angularjs.org/1.3.10/angular.js" data-semver="1.3.10"></script>
<script>
var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope) {
$scope.checked = true;
$scope.unchecke = function(checked){
if(checked){
$scope.checked = false;
}else{
$scope.checked = true;
}
};
});
</script>
</head>
<body ng-controller="MainCtrl">
<input type="checkbox" ng-model="checked | lowercase" ng-click="unchecke(checked)" id="ids" name="ids">
</body>
</html>