Friday, August 8, 2014

AngularJS: $element injecting into controller not for Routing

$element can be injected into controller in normal cases but not in routing

I got the explanlation from here:

 your "typical" controller in fact IS a directive controller! So the injectable locals just happen to be available to any controller using ngController. But it's NOT available using a route because ngView uses a more "normal" controller instantiation


It throws error like this if you try in routing ( in the routing controller ):


Error: [$injector:unpr] http://errors.angularjs.org/1.2.15/$injector/unpr?p0=%24elementProvider%20%3C-%20%24element
    at Error (native)
    at https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js:6:450
    at https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js:34:510
    at Object.c [as get] (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js:33:83)
    at https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js:35:59
    at c (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js:33:83)
    at d (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js:33:300)
    at Object.instantiate (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js:33:464)
    at $get (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js:65:486)
    at link (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular-route.js:913:26) <div ng-view="" class="ng-scope"> 


No comments:

Post a Comment