Reputation: 121
i have a question on how to get variables set in my controller in a html tag?
Example:
<table class="table table-striped table-bordered table-hover" ng-hide="checked">
The ng-hide should be a variable. In my controller i have:
$scope.checked = "checked";
How to use the variable in the above example?
<table class="table table-striped table-bordered table-hover" ng-hide="{{ checked }}">
Doesnt work.
Upvotes: 0
Views: 80
Reputation: 28592
ng-hide ng-show ng-desabled all of them rely on a true/false variable,
So you have to consider a $scope.checked=false or true in your controller , and that will work
Upvotes: 1
Reputation: 337
I can give you this.
<!DOCTYPE html>
<html ng-app>
<head>
<title></title>
<script type="text/javascript" src="angular.min.js"></script>
<script type="text/javascript">
function testCtrl ($scope) {
$scope.checked = true;
$scope.changeHide = function(){
$scope.checked = false;
}
}
</script>
</head>
<body ng-controller="testCtrl">
<div ng-show="checked">
Must be shown on start.
</div>
<button ng-click="changeHide()">Hide</button>
</body>
</html>
ng-show or ng-hide , it does not matter.
Upvotes: 0