简体   繁体   中英

Ionic 3: Return on If inside function subscribe()

So I added an if conditional into my subscribe() and I used return; to break if it's satisfied however it's not breaking the big function and only breaks the subscribe() and it goes through to the navCtrl.push line, what can I do?

 grabInfo(){ this.ServiceProvider.grabRAW(this.email).subscribe(data => { this.infoList = data.data; if (this.infoList == null){ loader.dismiss(); toast.present(); return;} //console.log(this.infoList); this.navCtrl.push(ResultPage,{infoList: this.infoList}); } ); } 

Fixed, there ya go if you ever meet this

  grabInfo(){ this.ServiceProvider.grabRAW(this.email).subscribe(data => { this.infoList = data.data; if (typeof this.infoList[0] != 'undefined'){ this.navCtrl.push(ResultPage,{infoList: this.infoList})} else{ loader.dismiss(); toast.present(); } } ); } 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM