title: Benefit of using ionic2 ionViewCanLeave Navigationguard to respond to alert to stay or leave page
body: <p>Can't see the point at present to use such a navigationguard because we don't know about the target page to navigate to (active page info is avaible from the navController getActive() method). Typically we'll be using an alert to ask the question "Do you really want to leave this page?" in response to a menu option being selected for example and on OK, as far as I can tell, we don't know which page to "setRoot" to as the target page because the ionViewCanLeave handler has no parameters such as toPage/enteringPage.</p>
  
  <p>Has anyone managed to do this yet or rather find out from the navigation objects in ionic2 target page information? </p>
  
  <p>Here a little code to set context:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>ionViewCanLeave(): boolean { // no parameters on offer :-( 
      let result: boolean = false;
      let alert: Alert = this._alertCtrl.create({
        title: 'Are you sure you want to leave..?',
        message: 'Your changes will be lost if you do?',
        buttons: [
          {
            text: 'Cancel',
            role: 'cancel',
            handler: () =&gt; {
              let dismiss: boolean = true;
              return dismiss;
            }
          },
          {
            text: 'OK',
            handler: () =&gt; {
              let dismiss: boolean = false;
              let alertPop = alert.dismiss();
              alertPop
                .then(() =&gt; {
                  let rootNav: NavController = this._appCtrl.getRootNav();
                  this._navCtrl.pop();
                  this._navCtrl.setRoot(DashboardPage); // Here we want to parameterize to target page - hardcoded for now
                });
              return dismiss;
            }
          }
        ]
      });
      if (this._applicationService.getOfferStatus() === OfferStatus.live) {
        alert.present();
      }
      return result;
    }</code></pre>
  </div>
  </div>
  </p>