Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Angular build breaks controller scope #646

fiveisprime opened this Issue · 3 comments

3 participants


Version 0.9.4

When controllers are minified, $scope is changed to a which breaks the controllers.

To reproduce:

yeoman init angular
yeoman build

Then run the app from dist which results in the following error: Error: Unknown provider: aProvider <- a


If I understand the issue report correctly I don't think this is a Yeoman issue. I think you need to inject your $scope when using minifiers with AngularJS:

myApp.controller('myCtrl', ['$scope', function($scope) {
        $scope.myVar = 'foo';

That way it will preserve the $scope variable after the minification process is finished.


Thanks for the response - that fixed my issue. Maybe this should be a generator issue then as the controller generated by yeoman init angular:controller Name has to be modified before it will work with the build process.

Thanks again. :)


You're welcome. I'm still learning AngularJS and I'm only a couple of days in. I had the same issue a couple of days ago.

Although I think your suggestion would probably work as an advisory and encourage people to do the dependency injection as it should be done in relation with minification, I think it would be difficult to wire it up all the way through in the generators... but then again, the guys working on Yeoman and the generators impress me continuously, so maybe they will come up with something :-) ! I think you would probably still need to inject your custom made modules "by hand" to some extend along the way.

I agree with your point about the controller generator should work with the build process out of the box.

@hemanth hemanth closed this
@Xspirits Xspirits referenced this issue from a commit in Xspirits/angular
@Xspirits Xspirits fixed issue with js minifying see yeoman/yeoman#646 404ab65
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.