AngularJS 2.0 From The Beginning

  • Just like previous versions of Angular, Angular 2 also contains some built in directives and also allows us to create Custom Directives.
  • To create attribute Directives, we always need to use or inject the objects given below in our custom attribute Directive component class.
  • In the article, we will discuss about the attribute Directives in Angular 2.
  • It can change DOM element or add any new DOM element or remove any DOM element.
  • HostListener Some times, we may need to access an input property within the attribute directive, so that as per the given attribute directive, we can apply the related attribute within DOM element.

In this article, you will learn about the attribute directives in AngularJS 2.0.

@debasiskolsaha: AngularJS 2.0 From The Beginning – Attribute Directives – Day Six…

I am here to continue the discussion around AngularJS 2.0. Today, we will discuss the output property binding in AngularJS 2. Also, in case, you did not have a look at the previous articles of this series, go through the links, mentioned below.

In my previous article, I already discussed about the different process of data binding techniques including input property binding mechanism and output property for the Event Emitter in case of components within Angular 2.0. Now, in this article, I will discuss about the Directive concept in Angular 2. Before starting discussion about directive in Angular 2, first of all, we need to understand what directive is. As per Google, Directives are markers on a DOM object model or element (such as an attribute, element name, comment or CSS Class) that tells AngularJS’s HTML compiler to attach a specified behavior to that DOM element or even to transform the DOM element and its child objects. Just like previous versions of Angular, Angular 2 also contains some built in directives and also allows us to create  Custom Directives.

In Angular 2, basically the directives are also a component. Basically, there are three types of Directives in Angular 2, which are listed below.

In this article, we will discuss about the attribute Directives in Angular 2. The attribute Directive changes the appearance or behavior of a DOM element. These Directives look like regular HTML attributes in the templates and ngModel Directive, which is used for two-way is a perfect example of an attribute Directive. To create attribute Directives, we always need to use or inject the objects given below in our custom attribute Directive component class.

AngularJS 2.0 From The Beginning

You might also like More from author

Comments are closed, but trackbacks and pingbacks are open.