在父项中单击时';s html,在Angular 2/Ionic中调用子方法
我面对这种情况已经有好几个小时了,但我找不到合适的答案。我用角2和离子2 我有1页(主页-home.ts,home.html) 和1组件(谷歌地图,谷歌地图.ts,谷歌地图.html) 在home.html中,我有:在父项中单击时';s html,在Angular 2/Ionic中调用子方法,html,angular,ionic-framework,ionic2,angular2-directives,Html,Angular,Ionic Framework,Ionic2,Angular2 Directives,我面对这种情况已经有好几个小时了,但我找不到合适的答案。我用角2和离子2 我有1页(主页-home.ts,home.html) 和1组件(谷歌地图,谷歌地图.ts,谷歌地图.html) 在home.html中,我有: <ion-header> <ion-navbar> <ion-buttons end> <button ion-button (click)="findMyLocation()">Find</button
<ion-header>
<ion-navbar>
<ion-buttons end>
<button ion-button (click)="findMyLocation()">Find</button>
</ion-buttons>
</ion-navbar>
</ion-header>
您可以尝试以下方法:
<google-maps #googlemaps></google-maps>
然后像这样使用它:
<button ion-button (click)="googlemaps.findMyLocation()">Find</button>
查找
我尝试了一个简单的例子,它的工作。到目前为止,我还没有在文档中找到任何东西,所以我不能告诉你这到底是怎么回事。似乎#创建了一个引用组件的局部变量,您可以在当前范围内使用它。Thank's!这就是我要找的。
<button ion-button (click)="googlemaps.findMyLocation()">Find</button>