These are the most common terms used while creating custom directives in Angular.

Before we start our discussions about the topic,

Are you preparing for interviews? Here are frequently asked interview questions in Angular. It covers the Latest interview questions for Angular and Frontend development. Let’s check how many of these questions you can answer?

If you are looking for the checklist to optimize the angular application performance check these articles.

Let’s continue our discussion

import {Component,HostListener,Directive,HostBinding,Input} from '@angular/core';
@Directive({selector: '[customdirective]'})
export class CustomDirective {
  @HostBinding('attr.access') access = 'masteraccess'; 
  @HostListener('click') onClick() {
    this.access= this.access === 'masteraccess' ? 'normalaccess' :   'masteraccess';
  }
}

#typescript #angular #javascript #angular-4

HostBinding and HostListener: what do they do and what are they for?
2.20 GEEK