1

Im using Angular 1.5 and building an application in the component structure. I get an Unknown Provider Error when I'm attempting to inject into the $canActivate hook (which shouldn't happen) So heres the code:

angular.module("app")
.component("index", {
    templateUrl:"/modules/index-app.component.html",
    $canActivate:function($timeout) { <-- Creates Error
        return $timeout(function() {
            console.log('Timeout fired')
        }, 2000);
    },
    controller:function($timeout, $location, authCookie) {  
        // Set 'this'
        var model = this
    },
    controllerAs:"model",
});

Im running Angular 1.5.3 if that makes any difference? If I don't inject into the Hook then it runs everything fine. I'd love to know people's thoughts :)

HireLee
  • 561
  • 1
  • 9
  • 25
  • 3
    You are are using unminified code? Or it's uglified that throws this? Try `$canActivate: ['$timeout', function($timeout) { }]`. – dfsq May 09 '16 at 12:12
  • 1
    @dfsq Its always the simple things that are overlooked. I'm using Gulp to minify the code. Thanks this solved it :) – HireLee May 09 '16 at 12:40

0 Answers0