#native_company# #native_desc#
#native_cta#

Overview

We’ve covered Components in the last section, in this section and the next we’ll cover the concept of Directives.

We’ve touched on a few directives already, such as NgFor.

Directives are components without a view. They are components without a template. Or to put it another way, components are directives with a view.

Everything you can do with a directive you can also do with a component. But not everything you can do with a component you can do with a directive.

We typically associate directives to existing elements by use attribute selectors, like so:

<element aDirective></element>

Tip

We capitalise the name of directives when we are talking about the directive class. For example when we say NgFor we mean the class which defines the NgFor directive.

When we are talking about either an instance of a directive or the attribute we use to associate a directive to an element we lowercase the first letter. So ngFor refers to both the instance of a directive and the attribute name used to associate a directive with an element.

In this section we are going to cover the built in directives that come bundled with Angular.


Caught a mistake or want to contribute to the book? Edit this page on GitHub!



Advanced JavaScript

This unique course teaches you advanced JavaScript knowledge through a series of interview questions. Bring your JavaScript to the 2021's today.

Level up your JavaScript now!