DEV Community

Ovidiu Miu
Ovidiu Miu

Posted on

1

Angular: Where does the term 'directive' come from?

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.

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

AWS GenAI LIVE!

GenAI LIVE! is a dynamic live-streamed show exploring how AWS and our partners are helping organizations unlock real value with generative AI.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️