We know what directives are and we have used them all along: ng-click
, ng-show
, ng-style
, and ng-repeat
are all directives. These are JavaScript objects defined using the directive
function of the Module API. Once constructed, they are either attached to existing HTML elements or extend the existing HTML vocabulary with new elements/tags.
Directives have been conceptualized and incorporated into the framework in such a way that they allow the integration of controllers and views naturally and in a less verbose manner. It's the job of a directive to orchestrate the interaction between the controller and the view, keeping the separation of concerns intact.
From a functional standpoint, there are broadly two families of directives:
Directives that extend the behavior of existing HTML element, such as
ng-click
,ng-show
, andng-style
.Component directives come with their own view templates and behavior. The one place that we have used such a directive is with the
$modal...