The ng-hide
directive hides the element depending on the result of the expression that is specified in the attribute.
Example:
<button ng-hide="esconderBotao">Botao 1</button>
If the variable esconderBotao
is declared in scope and is TRUE (or something equivalent) the button will be hidden (the .ng-hide class is added to the element).
Another example:
angular.module('App', [])
.controller('ExemploController', ['$scope', function($scope) {
$scope.esconderBotao1 = false;
$scope.botao1 = function() {
alert('Ok!');
}
}]);
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script><divng-app="App">
<div ng-controller="ExemploController">
<button ng-click="botao1()" ng-hide="esconderBotao1">Botao 1</button>
<br /><br />
<button ng-click="esconderBotao1 = true" ng-show="!esconderBotao1">Esconder botão 1</button>
<button ng-click="esconderBotao1 = false" ng-show="esconderBotao1">Mostrar botão 1</button>
</div>
</div>
In the example above, when you click the "Hide" button, the variable esconderBotao1
(see ng-click) is set to TRUE and button 1 is hidden automatically. By clicking the "Show" button the esconderBotao1
variable is set to FALSE and button 1 is automatically displayed.
Note: If you do not set a value for the variable in scope, the ng-hide element will not hide the element by default.