python ruby-programming-language Smalltalk Vue.js Knockoutjs TypeScript JavaScript, OOPs JavaScript Angular 7, Interview Questions Angular 8,7,6,5,4 and 2 Interview Questions and Answers Angular 8,7,6,5,4 and 2 Interview Questions and Answers Angular 4 Angular 2 AngularJs 1.x NodeJs Perl Programming R Programming RequireJs Rust Programming Backbonejs closure programming language go-programming-language kotlin-programming-language

What Are Angular Decorators?

What Are decorators?
The Decorators are functions that modify JavaScript classes and it also used for attaching metadata to classes.

Directive decorator and metadata Properties -
    selector?: string
    inputs?: string[]
    outputs?: string[]
    host?: {...}
    providers?: Provider[]
    exportAs?: string
    queries?: {...}

Selector – It is a CSS selector that tells Angular to create an instance of this component wherever it finds the corresponding tag in template HTML.

For example, it is – <app-login></app-login>

CSS selector also triggers the instantiation of a directive.
The selector may be declared by element name, class name, attribute name, and attribute name & value.

Suppose we have a directive with an <input type="checkbox"> selector and the HTML looks like this.
 <label>Name -</label> <input type="text">
 <label>Are you agree? </label> <input type="checkbox">

The directive will only be instantiated on the <input type="checkbox"> element.

Inputs– The list of class property names to data-bind as component inputs

Outputs - The list of class property names that expose output events that others can subscribe too

Host– These properties use to map the class property to host element bindings for properties, events, actions, and attributes.

The host looks like this.
  selector: 'button',
  host: {'(click)': 'onClick($'}

Providers - list of providers available to this component and its children
Queries– To configure queries that can be injected into the component

For more detail kindly refer the link.... 

Hi there! Welcome to my blog. My name is Anil Singh. I'm a author of this blog. For more detail about me, kindly refer to this link..
My Blogs - and
My Books - Interview Questions and Answers Books- Get Your Book in 15+ Digital Stores Worldwide..

You Might Also Like Powered by Blogger.
ASK Questions