I have created an app based on ng-boilerplate. All works just fine. However, now I am coming close to deployment, I want to compile and minify the code. This is straighforward enough using grunt compile, but of course the app breaks when minified. I didn't expect anything less!
I have injected dependencies into my controllers like this:
var appCtrl = app.controller('AppCtrl', function AppCtrl($scope, $rootScope, helpService, userService, menuService, $location) {... body ...});
appCtrl.$inject = ['$scope', '$rootScope', 'helpService', 'userService', 'menuService', '$location'];
I have also tried it like this:
var appCtrl = app.controller('AppCtrl', ['$scope', '$rootScope', 'helpService', 'userService', 'menuService', '$location',
function AppCtrl($scope, $rootScope, helpService, userService, menuService, $location) {... body ...}]);
All I ever get is an error like this: Error: Unknown provider: aProvider <- a
I have also looked at my services and injected the dependencies in a similar way to the second method above, but then I started getting errors in the program even when it was not minified. It was telling me $q has no method defer()!
app.factory('checkAuth', ['$q', '$location', '$filter', '$rootScope', function ($q, $location, $filter, $rootScope) {...body...}]);
My question is, what am I missing? Am I doing the dependency injections correctly? Is there somewhere else needing DI?
Thanks!
EDIT: Just found this: Angular.module minification bug
It hasn't completely fixed the problem... I now get the error:
TypeError: Object #<error> has no method 'slice'
but at least this is away from Error: Unknown provider: aProvider <- a :-)