jbgarr
jbgarr

Reputation: 1398

How to access the previous route from Durandal router

Is there a way to access the previous route/instruction from the Durandal.js router? I know I can do router.navigateBack() to actually navigate back, but I want to know the route that I will navigating back to before I trigger the navigation.

Upvotes: 0

Views: 986

Answers (1)

Maleki
Maleki

Reputation: 4318

Not directly I'm afraid.

router.navigateBack() is defined in router.js as

    router.navigateBack = function() {
        history.navigateBack();
    };

And history.navigateBack() is defined in history.js as

    history.navigateBack = function() {
        history.history.back();
    };

and history.history is an alias defined above for window.history which is part of the browser and would cause security issues if exposed.

If you want to have that functionality you'll have to implement it yourself. Possibly by intercepting router.navigate() and router.navigateBack().

Upvotes: 1

Related Questions