Angular 4 父組件調用子組件中的方法

1. 創建工程

ng new demo3

2. 創建子組件

ng g component child

3. 在子組件中定義方法greeting

 

4. 父組件html(第三行是模板中調用子組件的方法)

5. 父組件Control調用子組件中的方法

 


本文轉自Work Hard Work Smart博客園博客,原文鏈接:http://www.cnblogs.com/linlf03/p/7260266.html,如需轉載請自行聯繫原作者