Reputation: 11375
I'm working with angular js and there's one thing I didn't fully understand yet. I know what directives are: they are "additional features" that we add to HTML that can be used as elements, attributes, comments or classes and that can change completely the markup there by some other thing rendered by angular or can add functionality with the link function.
That's fine, but when to use directives? I know that if we want to represent on screen some domain specific object then this is one possible candidate for a directive, or when we want to add functionality to some HTML element (like slider functionality to an input) then we use a directive. But what about other cases? What about when we want to manipulate the DOM to, for instance, activate the functionality of a sidebar or thing like that? Directives are used for this to?
How do when know when to use a directive in angular?
Upvotes: 3
Views: 162
Reputation: 35900
ng-include
).ng-model
ed input field validates, formats, or parses, create a directive that requires ngModel
.require
the parent directive(s) and communicate via the directive controller(s).Upvotes: 2
Reputation: 1728
I think about directives when I face one of this two scenarios:
Upvotes: 4