What does the selector do in this case?
import { Component } from \'@angular/core\';
import { HighlightDirective } from \'./highlight.directive\';
@Componen
If we say in simple term selector is name which is used in our view like html tag. as we all know angular2 is component based. so selector is just provide the name of the component which is being called by its className in the directives list and called by selector name in the view of the another component like this:-
//suppose this is our component
@Component({
selector : 'mycomponent'
....
})
export class Mycomponent{ }
now we can use this component in another component like this -
@Component({
selector : 'secondcomponent',
directives: [Mycomponent], //here we use class name instead of selector name
template: ' ' //here we used selector name
....
})
export class Mycomponent{ }
Also we can say selector is a complete functionality name used as html tag in the view.