2015-04-09 20:36:17 +02:00
|
|
|
# .cadoles-slide-title[Les directives de base (5/5)]
|
2015-04-08 23:22:53 +02:00
|
|
|
|
2015-04-09 20:36:17 +02:00
|
|
|
**Inclusion de template avec la directive `ng-include`**
|
2015-04-08 23:22:53 +02:00
|
|
|
|
2015-04-09 20:36:17 +02:00
|
|
|
```html
|
2015-04-08 23:22:53 +02:00
|
|
|
|
2015-04-09 20:36:17 +02:00
|
|
|
<!-- Fichier index.html -->
|
2015-04-08 23:22:53 +02:00
|
|
|
|
2015-04-09 20:36:17 +02:00
|
|
|
<html>
|
|
|
|
<body ng-app>
|
|
|
|
<ng-include src="'template1.html'"></ng-include>
|
2015-04-08 23:22:53 +02:00
|
|
|
<script src="angular.js"></script>
|
|
|
|
</body>
|
|
|
|
</html>
|
2015-04-09 20:36:17 +02:00
|
|
|
|
|
|
|
<!-- Fichier template1.html -->
|
|
|
|
|
|
|
|
<div>
|
|
|
|
<div ng-controller="MyCtrl">
|
|
|
|
<!-- ... -->
|
|
|
|
</div>
|
|
|
|
</div>
|
2015-04-08 23:22:53 +02:00
|
|
|
```
|
2015-04-09 20:36:17 +02:00
|
|
|
|
|
|
|
- Les templates peuvent être chargés dynamiquement, à la volée.
|
|
|
|
- Il est possible de les précompiler et de les inclures sous leur forme Javascript lors de la mise en production
|