ng-click="(document.getElementById('procheck1').checked)?showme=true:showme=false"
(或)
ng-click="if(document.getElementById('procheck1').checked){showme=true;}else{showme=false;}"
答案 0 :(得分:0)
使用像这样的函数名,ng-click =“myFunction()”并在其中写入整个条件。
myFunction(){
if(document.getElementById('procheck1').checked) {
showme=true;
} else {
showme=false;
}
}
答案 1 :(得分:0)
在html页面中试试这个
<div ng-app="MyApp" ng-controller="MyController">
<label for="chkPassport">
<input type="checkbox" id="chkPassport" ng- model="ShowPassport" ng-change="ShowHide()" />
Do you have Passport?
</label>
<hr />
<div ng-show="IsVisible">
Passport Number:
<input type="text" id="txtPassportNumber" />
</div>
</div>
这部分在控制器中
var app = angular.module('MyApp', [])
app.controller('MyController', function ($scope) {
//This will hide the DIV by default.
$scope.IsVisible = false;
$scope.ShowHide = function () {
//If DIV is visible it will be hidden and vice versa.
$scope.IsVisible = $scope.ShowPassport;
}
});