This is a migrated thread and some comments may be shown as answers.

Is possible to cancel router navigation using promise ?

2 Answers 145 Views
SPA
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 09 Feb 2017, 09:52 AM

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 Answers, 1 is accepted

Sort by
0
Accepted
Boyan Dimitrov
Telerik team
answered on 13 Feb 2017, 07:57 AM

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.
0
John
Top achievements
Rank 1
answered on 13 Feb 2017, 08:21 AM

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

Just wondering if there is an official support.

 

thanks

Tags
SPA
Asked by
John
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
John
Top achievements
Rank 1
Share this question
or