ngSwitch/Show/Hide

by Dor Cohen

HTML

<script src="http://code.angularjs.org/1.1.3/angular.js"></script>
<div ng-controller='myCtrl'>
  <div ng-switch="type">
    <div ng-switch-when="1">Type is 1</div>
    <div ng-switch-when="2">Type is 2</div>
    <div ng-switch-default>Type is unknown</div>
  </div>
  <div ng-show='type==2'>Yay!</div>
  <div ng-hide='type==2'>Nay!</div>
</div>

JavaScript

var myApp = angular.module('myApp', []);

function myCtrl($scope) {
  $scope.type = 2;
}