Issues on first launch: input value empty + nav button works on 2nd click [resolved]


#1

Hello

I want to get the text typed in an ion-input to suggest words associated (autocomplete). It works well except on the first launch of my app. On the first launch, the value of the input is always empty. I tried to reproduce the issue in a codepen but couldn’t make it happen.

<ion-input id="keyword" type="search" placeholder="Type something" class="cat-input" 
		 [(ngModel)]="category" (input)="doAutocomplete()" (search)="goToList(category)"> </ion-input>

 doAutocomplete(){
     let input=document.getElementById('keyword').getElementsByTagName('input')[0].value;
     console.log(input);
 }

I get the input value manually because if I take the binded value (category) it is always missing the last letter (I guess the function is fired before the value is updated).

Also, I don’t know if it is related but I have another issue that happens only at first launch: buttons that open a new page have to be clicked twice. The page code is executed each time (ngAfterViewInit is executed twice) but it is displayed only the second time and the page isn’t duplicated in the navigation stack .

How can I find out what causes this bug ?


#3

The issue was caused by a hack I made to display a tutorial page on first launched. I was inserting it at position 0 and then popping the current page and now I’m using setRoot instead and it works perfecty!