0
votes

I want to console.log when the router changes only from "home" to "aboutpage" or any other page, but from the homepage.

I am not able to come up with any logic so havent tried anything.

1

1 Answers

1
votes

try something like this

Router.route('/', {
    name : 'home',
    template : 'home',
    title: 'Home'
});

Router.route('/about', {
    name : 'about',
    template : 'about',
    title: 'About'
});

Router.onStop(function(){
     Session.set("previousPath",Router.current().route.getName());
});

Router.onBeforeAction(function(){
    if(Session.get("previousPath")=="home"){
        console.log('something')
    }
    this.next()     
})