angular2-authentication-sample icon indicating copy to clipboard operation
angular2-authentication-sample copied to clipboard

Avoided Route still load

Open jackesdavid opened this issue 9 years ago • 0 comments

( sorry about my english)

i think the code need a little change. If you want to avoid a route you need to skip activation, so my propose is We dont need to do load a route if will be avoided, so do not activate yet

    activate(instruction:ComponentInstruction)
    {
        var url = this.parentRouter.lastNavigationAttempt;
        //check in your way if the route is valid...
       // is not valid
        if (instruction.urlPath != 'About')
        {
            this.parentRouter.navigate(['/About']);
        }
        //is Valid
        else
        {
            return super.activate(instruction);
        }
    }

jackesdavid avatar Jan 11 '16 19:01 jackesdavid