Thursday, October 11, 2018

Output properties in Angular

Output properties are outbound properties which flows from a child component to its parent component. These are events which originate from the child component and get handled in the parent component.

Output properties are marked with the @Output decorator and returns an Angular EventEmitter.
Output properties are declared using the @Output decorator as follows.



@Output() propertyName = new EventEmitter();

Once the property is declared in a component, we can use it to emit events to the parent component using .emit. Also we need to specify the property when adding the child component to the parent component.



Here outputProperty is a the @Output property defined in the child and handled by the parent component. 'eventHandlerFunction is the function which handles the event emitted from the parent component. 

Search Flipkart Products:
Flipkart.com

No comments: