How to provide information for canDeactivate in Aurelia view-model

I use canDeactivate()in the view model. The user can move from the view, where he canDeactivatedoes not have to perform his checks and simply return true (in this case, when the user clicks the "Back" button, which is in another view). It canDeactivatedoesn't seem to accept any arguments (such as parameters passed to router.navigateToRoute). If this happened, I could indicate that the back button was pressed in the arg parameter when called navigateToRoute. What would be a good way to give canDeactivatethis necessary information?

+4
source share
3 answers

( ), "".

0

aurelia-router 1.4.0, canDeactivate , ,

+1

I'm not sure if I understood your question ... In any case, you can access the properties of the class inside canDeactivate(). For instance:

canDeactivate() {
   //before calling router.navigateToRoute
   //you can set some properties to indicate the origin, the pressed button or wathever

   if (this.someProperty === true) {
      return true;
   }

   return false;
}
0
source

Source: https://habr.com/ru/post/1648672/


All Articles