Netanel Basal

--

--

Angular v14.1.0 added a new property named code to the NavigationCancel event. It contains a code that indicates why the navigation was canceled. The code is an enum with the following options:

NavigationCancellationCode.Redirect — A navigation failed because a guard returned a UrlTree to redirect.

NavigationCancellationCode.SupersededByNewNavigation — A navigation failed because more recent navigation started.

NavigationCancellationCode.NoDataFromResolver —A navigation failed because one of the resolvers completed without emitting a value.

NavigationCancellationCode.GuardRejected — A navigation failed because a guard returned false.

When navigation is canceled, we can determine the reason for the cancellation and perform different actions as needed:

Follow me on Medium or Twitter to read more about Angular and JS!

--

--

Netanel Basal

Netanel Basal

A FrontEnd Tech Lead, blogger, and open source maintainer. The founder of ngneat, husband and father.