Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在父项中单击时';s html,在Angular 2/Ionic中调用子方法_Html_Angular_Ionic Framework_Ionic2_Angular2 Directives - Fatal编程技术网

在父项中单击时';s html,在Angular 2/Ionic中调用子方法

在父项中单击时';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

我面对这种情况已经有好几个小时了,但我找不到合适的答案。我用角2和离子2

我有1页(主页-home.tshome.html

1组件(谷歌地图,谷歌地图.ts谷歌地图.html

home.html中,我有:

<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>