Tomasz BiaĆecki
At a high level, directives are markers on a DOM element (such as an attribute, element name, comment or CSS class) that tell AngularJS's HTML compiler to attach a specified behavior to that DOM element or even transform the DOM element and its children.
... to manipulate the DOM directly
... to remove repeated codes
... to create new HTML mark-up for non-developers to use
.directive('myDirective', function(){
return {
restrict:'E'
}
});
.directive('myDirective', function(){
return {
restrict:'A'
}
});
.directive('myDirective', function(){
return {
restrict:'C'
}
});
.directive('myDirective', function(){
return {
restrict: 'ACE'
scope: false //no scope (use parent scope)
}
});
.directive('myDirective', function(){
return {
restrict: 'ACE'
scope: true //create child scope
}
});
.directive('myDirective', function(){
return {
restrict: 'ACE'
scope: { //create new isolated scope
}
}
});
ngRepeat
ngShow / ngHide
ngClass
ngDisabled
ngIf / ngInclude