1.

What are the decorators and how do you create this?

Answer»

Decorators are actually just functions that are called as per the component they are handling. A class decorator SHALL be called with the class being decorated and similarly for a method decorator. Here’s how to CREATE a decorator in Angular 6:

Example

STEP 1:
function CONSOLE(target) {
    console.log('Our decorated class', target);
}

Step 2:
@Console
class ExampleClass {
    constructor() {
        console.log('Hello!');
    }
}



Discussion

No Comment Found