Sunday, 14 February 2016

Directives in angular 2

Directives are classes which get instantiated as a response to a particular DOM structure. We use Directives to break complex problems into smaller more reusable components.

There are three kinds of Angular directives:

  1. Components
  2. Attribute directives
  3. Structural directives

Component

The Component is really a directive with a template. It's the most common of the three directives and we write lots of them as we build our application.

Components are typically used to create UI widgets or to break up the application into smaller components.

Attribute directives

The Attribute directive changes the appearance or behavior of an element. The built-in NgStyle directive, for example, can change several element styles at the same time.

Structural directive

The Structural directive changes the DOM layout by adding and removing DOM elements. NgFor and NgIf are two familiar examples.

No comments:

Post a Comment