formations/javascript/angular/directives-3.md

23 lines
616 B
Markdown

# .cadoles-slide-title[Les directives de base (3/5)]
**Conditions dans les templates: `ng-show`, `ng-hide`, `ng-switch`**
```html
<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="myVar">
<span ng-switch-when="foo">Affiché !</span>
<span ng-switch-when="bar">Caché !</span>
<span ng-switch-default>Caché !</span>
</div>
</div>
<script src="angular.js"></script>
</body>
</html>
```