Is possible to cancel router navigation using promise ?

3 posts, 1 answers
  1. John
    John avatar
    2 posts
    Member since:
    May 2014

    Posted 09 Feb Link to this post

    documentation for router change event says that navigation can be canceled with preventDefault

    but i want to ask user before leaving current view if is ok to leave unsaved changes.

    can be done using promises ?

  2. Answer
    Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    1929 posts

    Posted 13 Feb Link to this post

    Hello,

    I am afraid that the change event of the router does not offer promises. A possible solution for your case would be to cancel with preventDefault method and navigates (using the navigate method) if needed. 

    Regards,
    Boyan Dimitrov
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. John
    John avatar
    2 posts
    Member since:
    May 2014

    Posted 13 Feb in reply to Boyan Dimitrov Link to this post

    I allready use this solution. ( allways preventDefault and navigate if resolved ) and works fine.

    Just wondering if there is an official support.

     

    thanks

Back to Top