formations/javascript/angular/directives-4.md

632 B

.cadoles-slide-title[Les directives de base (4/6)]

Conditions dans les templates: ng-show, ng-hide, ng-switch

<html>
  <body ng-app="myApp">
    <div ng-controller="MainCtrl" ng-init="myTest = true; myVal = 'foo'">

      <span ng-hide="myTest === true">Caché !</span>
      <span ng-show="myTest === true">Affiché !</span>

      <div ng-switch="myTest === true">
        <span ng-switch-when="foo">Affiché !</span>
        <span ng-switch-when="bar">Caché !</span>
        <span ng-switch-default="baz">Caché !</span>
      </div>

    </div>
    <script src="angular.js"></script>
  </body>
</html>