October 2017
Intermediate to advanced
280 pages
6h 50m
English
Here is an example of using the decorators defined by Angular:
@Component({
selector: 'app',
providers: [NamesList],
templateUrl: './app.html',
})
export class App {}
When decorators accept arguments (just like Component in the preceding example), they need to be defined as functions that accept arguments and return the actual decorator:
function Component(config) {
// validate properties
return (componentCtrl) => {
// apply decorator
};
}
In this example, we defined a function called Component that accepts a single argument called config and returns a decorator. On the other hand, the decorator accepts the constructor function as argument, which is the desugared version of the class.
Read now
Unlock full access