selector

The selector is a property of the @Component annotation, and its value (of type string) is what gives the name to our custom HTML tag. I like cars, so here's an example car component in code, showing its annotation, selector, and class name:

@Component({
selector: 'car'
})
class CarComponent {
}

When Angular sees our custom HTML tags, <car></car>, it creates an instance of our CarComponent and will replace our custom tags with some HTML that the browser actually understands. OK, but where in our component class do we add stuff to give our component something more than a ghostly aura? The next section is the answer (that is, the template property).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.216.186.164