Reputation: 1990
I am learning angular 6. There is something I am trying to understand, but still cannot fully understand. It is decorator. Decorator can be use on classes, method, variable, ... I have read multiple articles about this topic. But still don't get all.
Can you please explain it with simple world ? with examples.
Thanks in advance
Upvotes: 1
Views: 99
Reputation: 396
Decorators are actually just functions, it’s as simple as that, and are called with whatever they are decorating. A method decorator will be called with the value of the method it’s decorating, and a class decorator will be called with the class to be decorated.Here is an example of custom decorator.
function Console(target) {
console.log(target);
}
@Console("hey")
class ExampleClass {
constructor() {
console.log('Yo!');
}
}
to know more About Decorators I Found https://toddmotto.com/angular-decorators as best resource
Upvotes: 2
Reputation: 7105
Input is for passing an object from parent to child.
Ouput is for raising an event from child to parent.
https://www.sitepoint.com/angular-2-components-inputs-outputs/
Upvotes: 0