Angularjs   发布时间:2022-04-20  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ionic-framework – 如何从Ionic2中的离子输入中获取包裹的输入?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我想将google.maps.places.Autocomplete附加到离子输入,但在Ionic2离子输入中包含< 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没有.inputElement`.

任何想法都会受到欢迎.

谢谢!

解决方法

不确定这是你想要的(不知道离子)

<ion-input LOCATIOn-picker="">
    <input #myInput 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>
@ViewChild('myInput') input; 

ngAfterViewInit() {
  console.log(this.input.nativeElement.value);
}

另见angular 2 / typescript : get hold of an element in the template

大佬总结

以上是大佬教程为你收集整理的ionic-framework – 如何从Ionic2中的离子输入中获取包裹的输入?全部内容,希望文章能够帮你解决ionic-framework – 如何从Ionic2中的离子输入中获取包裹的输入?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。