Component Communication with Input and Output
In Angular 1 we use$broadcast, $emit, $on
to communicate between controllers. You can refer my previous blog if you want to know more on this.
We have same similar thing in Angular 2, But the coding is diffrent. Like say to flow data parent to child we will use
@Input
and @Output
to flow data child to parent component. You can update input properties using property bindings [property]
. And you can subscribe to output properties using event bindings (event)
.
You can use it in either
"inputs"
and "outputs"
properties in the @Component decorator or in the Class. It's upto your own taste. We will go through both the way.
No comments:
Post a Comment