0

I have created a project in stackblitz to easily see what is happening. I am calling a method from one component using a button in another component. It executes the method but for some reason is not bidding the variables.

https://stackblitz.com/edit/angular-com1-com2?file=src%2Fapp%2Fcom2%2Fcom2.component.ts

Please, do not forget to open the console in stackblitz to see more information.

Thanks in advance.

catra
  • 178
  • 2
  • 11

1 Answers1

1

You can use template variable and call child component like below:

<button (click)="childComp.modifyMessage()">change message</button>
<app-com2 #childComp></app-com2>
Mohammad Niazmand
  • 1,509
  • 9
  • 13
  • Hey @MohammadNiazmand I wanted to use your solution in the stackblitz but it doesn't work. Could you please do one sandbox and share the link? Thanks!! – catra Mar 25 '20 at 11:40
  • I missed double quotes.Just replace above code with in com1.component.html – Mohammad Niazmand Mar 25 '20 at 17:36