angularjs - Angular-JS strict-DI doesn't like injecting resolved results from $routeProvider -
i hit problems minifying angular code turned on ng-strict-di
one problem seems reside in way resolve promise on route in app.js config
.when('/:userid', { templateurl: 'views/main.html', controller: 'myctrl', resolve : { mydependency : function(cache, model, $route){ return cache.getcached( $route.current.params.userid); } } })
then inject resolved promise myctrl controller
angular.module('myapp') .controller('myctrl',[ 'mydependency', '$scope', '$rootscope', '$timeout', function (mydependency, $scope, $rootscope, $timeout) { etc...
however error angular
[error] error: [$injector:strictdi] mydependency not using explicit annotation , cannot invoked in strict mode
the problem appears traceable resolve definition in app.js because can change name of 'mydependency' there in resolve , error message uses name there rather name of dependency in myctrl. , explicitly listing name of dependency in myctrl controller. app works, cannot minify code because of problem error.
follow strict-di resolve well. hope works!
resolve : { mydependency : ['cache', 'model', '$route', function(cache, model, $route){ return cache.getcached( $route.current.params.userid); } ]}
Comments
Post a Comment