July 2017
Intermediate to advanced
454 pages
10h 1m
English
A class can be turned into a component by annotating it with @Component and passing the necessary metadata, such as selector, template, or templateUrl. Angular considers a class as a component only after attaching metadata to it:

Let's revisit the BookComponent class we defined earlier. Angular does not consider this class as a component unless we annotate it. TypeScript leverages the ES7 feature by providing a way to decorate a class with metadata as follows:
@Component({
selector: 'book-detail',
templateUrl: 'app/book.component.html'
})
export class BookComponent { ... }
Here, we have decorated the BookComponent class with @Component ...
Read now
Unlock full access