27 lines
546 B
Markdown
27 lines
546 B
Markdown
# .cadoles-slide-title[Création de directives (2/4)]
|
|
|
|
- Les directives peuvent prendre la forme d'éléments, d'attributs ou de classes.
|
|
|
|
```html
|
|
<script>
|
|
angular.module('myApp', [])
|
|
.directive('myDirective', function() {
|
|
return {
|
|
//Type de la directive: 'E' : Element, 'A': Attribut, 'C': Classe (ou composition des trois)
|
|
restrict: 'E'
|
|
};
|
|
|
|
})
|
|
;
|
|
</script>
|
|
|
|
<!-- Usage -->
|
|
|
|
<!-- "E" -->
|
|
<my-directive></my-directive>
|
|
<!-- "A" -->
|
|
<div my-directive></div>
|
|
<!-- "C" -->
|
|
<div class="my-directive"></div>
|
|
```
|