Skip to content

Instantly share code, notes, and snippets.

@ichaiwut
Last active June 16, 2017 09:25
Show Gist options
  • Save ichaiwut/2bcf42996e0ba89bd3f482956a9869f1 to your computer and use it in GitHub Desktop.
Save ichaiwut/2bcf42996e0ba89bd3f482956a9869f1 to your computer and use it in GitHub Desktop.
Nav Guard 1
export class MyClass {
constructor (public navCtrl: NavController) {}
//When trying to leave the page will call
//ionViewCanLeave()
pushPage() {
this.navCtrl.push(DetailPage)
.catch(()=> console.log(‘Something cache!’))
}
isValid() {
return (validValue) ? true : false;
}
//Make a decision to stay or leave.
ionViewCanLeave(): boolean {
return this.isValid();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment