kadoshms / ionic2-autocomplete

Ionic 2 autocomplete component
MIT License
149 stars 108 forks source link

Get value from viewChild searchbar is not getting #28

Closed rkmahale17 closed 7 years ago

rkmahale17 commented 7 years ago

cause error of getValue is undefine

code is like

@ViewChild('searchbar') searchbar: any; and calling function console.log(this.searchbar.getValue()); in autocomplete.componenent.ts

public getValue() { this.keyword return }

} in <ion-autocomplete #searchbar></ same>

kadoshms commented 7 years ago

I am not sure I am following (the code is a little bit messy to understand :) ) Anyways, Iv'e checked it up and everything looks fine (I updated README though):

my home.ts:

import {Component, ViewChild} from '@angular/core';
import { NavController } from 'ionic-angular';
import {CompleteTestService} from "../../app/auto";
import {AutoCompleteComponent} from "ionic2-auto-complete/dist";

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

  @ViewChild('searchbar')
  searchbar: AutoCompleteComponent;

  constructor(public navCtrl: NavController, private completeTestService: CompleteTestService) {

  }

  clicked() {
    console.log(this.searchbar.getValue());
  }

}

And my home.html:

<ion-header>
  <ion-navbar>
    <ion-title>Home</ion-title>
  </ion-navbar>
</ion-header>

<ion-content padding>
  <ion-auto-complete [dataProvider]="completeTestService" #searchbar></ion-auto-complete>
  <button (click)="clicked()">click</button>
</ion-content>
rkmahale17 commented 7 years ago

ionic2-auto-complete@1.4.2-rc0

kadoshms commented 7 years ago

@rkmahale17 I believe that this is not the same issue we were talking about

rkmahale17 commented 7 years ago

No this is not that issuse , after upgrating to ionic2-auto-complete@1.4.2-rc0.....label attribute issue solved ..but this function calling is not happening......

kadoshms commented 7 years ago

@rkmahale17 please review my latest comment in #42

rkmahale17 commented 7 years ago

Yes.... it is working....
Thank You so much......