Emmanuel Villegas
Emmanuel Villegas

Reputation: 1514

angular 2 how to bind two components behavior

I've two equal components

<component><component>

<component><component>

I need that if one of them change the another one change too, e.g if I've a function that when I click the element write 'hello' if i do it in one of them it be reflected in both components, how can i achieve that?

thanks in advance!

Upvotes: 2

Views: 108

Answers (1)

G&#252;nter Z&#246;chbauer
G&#252;nter Z&#246;chbauer

Reputation: 657008

<component #c1 (click)="c2.title = 'hello'"><component>

<component #c2 (click)="c1.title = 'hello'"><component>

For other ways see https://angular.io/docs/ts/latest/cookbook/component-communication.html

Upvotes: 2

Related Questions