【发布时间】:2017-04-27 05:57:06
【问题描述】:
我想将 google.maps.places.Autocomplete 附加到 ion-input,但在 Ionic2 ion-input 包装了 <input> 元素,我不知道如何访问它。
我尝试创建一个指令并使用传入的ElementRef
import {Directive, ElementRef, Input} from 'angular2/core';
@Directive({
selector: '[location-picker]'
})
export class LocationPicker {
constructor(el: ElementRef) {
console.log(el.nativeElement);
}
}
但 nativeElement 返回包装后的输入。
<ion-input location-picker="">
<input class="text-input ng-valid ng-dirty ng-touched" type="text" placeholder="" aria-labelledby="lbl-6" location-picker="" autocomplete="off" autocorrect="off">
<!--template bindings={}-->
<!--template bindings={}-->
<!--template bindings={}-->
</ion-input>
我也尝试过创建类似于this 的自定义组件并将Searchbar 切换为TextInput,但TextInput doesn't have.inputElement`。
欢迎提出任何想法。
谢谢!
【问题讨论】:
-
嘿,您能否提供完整的代码,说明您如何使用 ionic 2 实现 google 地方自动完成功能? :)。谢谢
标签: ionic-framework angular ionic2