I'm trying to understand the Angular terms and philosophy. One of the most basic building blocks of Angular seems to be a directive
.
As a non-native English speaker, I don't find this term intuitive, but rather abstract. So what's up with this term?
The Angular glossary says that "A [directive
is a] class that can modify the structure of the DOM or modify attributes in the DOM and component data model".
Ok, it got something to do with changing the DOM. But still, why 'directive'?
It got something to do with 'direction'?😄
Seems VueJS also has the concept of directive
.
VueJS docs: "If you have not used AngularJS before, you probably don’t know what a directive is. Essentially, a directive
is some special token in the markup that tells the library to do something to a DOM element."
This includes a reference to the AngularJS framework, and, yes, it seems AngularJS also has this term.
AngularJS docs: "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 ($compile) to attach a specified behavior to that DOM element (e.g. via event listeners), or even to transform the DOM element and its children."
Ok, so it seems that the term originally comes from AngularJS, and Angular and VueJS just inherited it.
I guess, in Layman terms, a directive
is a way of "teaching the HTML to do new tricks" (not mine).
But still... why directive
?
Still not sure, maybe the creators thought of this term because a directive
it's like commanding (giving directives/instructions/orders) to a static technology (HTML) in order to make it smarter.
Top comments (0)