NgShow Example

Angular JS

by Felipe Santos

HTML

<script src="https://code.angularjs.org/angular-1.0.1.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<div class="container" ng-app="showApp" ng-controller="mainController">

    <div class="page-header text-center">
       <h1>ngHide</h1>
    </div>

    <div class="row">
      <div class="col-md-12">
       <label>Nome: </label><input type="text" class="form-control" ng-model="nome" placeholder="Digite o seu nome"><br>
       <input type="checkbox" ng-model="oculta"> Clique para ocultar/exibir o nome
      </div>
      <div class="col-md-12">
        <h3 ng-hide="ocultar()">Olá, {{nome}}!</h3>
      </div>    
    
    </div>

CSS

.red{ background: red; width: 30px; height: 30px; }
.blue{ background: blue; width: 30px; height: 30px; }
.green{ background: green; width: 30px; height: 30px; }
.yellow{ background: yellow; width: 30px; height: 30px; }
.pink{ background: pink; width: 30px; height: 30px; }

JavaScript

var showApp = angular.module('showApp', [])

.controller('mainController', function($scope) {
	$scope.nome = "Felipe Pinheiro";
	$scope.ocultar = function(){
		return  $scope.oculta ? true : false;
	};
});