formations/javascript/angular/directives-3.md

23 lines
616 B
Markdown
Raw Normal View History

2015-04-09 20:36:17 +02:00
# .cadoles-slide-title[Les directives de base (3/5)]
2015-04-08 23:22:53 +02:00
2015-04-09 20:36:17 +02:00
**Conditions dans les templates: `ng-show`, `ng-hide`, `ng-switch`**
2015-04-08 23:22:53 +02:00
```html
<html>
<body ng-app="myApp">
2015-04-09 20:36:17 +02:00
<div ng-controller="MainCtrl" ng-init="myTest = true; myVal = 'foo'">
<span ng-hide="myTest === true">Caché !</span>
<span ng-show="myTest === true">Affiché !</span>
2015-04-08 23:22:53 +02:00
2015-04-09 20:36:17 +02:00
<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>
2015-04-08 23:22:53 +02:00
2015-04-09 20:36:17 +02:00
</div>
<script src="angular.js"></script>
2015-04-08 23:22:53 +02:00
</body>
</html>
```