Closed DallanQ closed 10 years ago
I am able to reproduce after running "grunt compile". It definitely has something to do with the minification, which is supposed to be handled by ngMin.
Running ngMin before uglify should not cause this problem. ngMin isn't doing what it's supposed to do, or else there's a bug in the implementation.
I'll have to debug this when I get time. Thanks for letting me know. In the meantime, you can get around the issue by manually naming the dependencies via...
myApp.controller('myCtrl', ['$scope', '$http', function($scope, $http) { }])
Thanks!
I've determined this is due to generator-ngbp being too "clever" with it's js code. ngmin only detects code it can alter via an "angular.module("blah", []).controller...". The fact that I'm using "app.controller..." is preventing ngmin from doing its thing.
There are two choices as I see it. One, we can just use declarative naming of dependencies. Two, we can see if we can help fix ngmin to be a tad smarter, maybe fork and use a convention of "app." or "module." to help trigger it's work.
I've submitted an issue with ngmin to see if it's worth the effort.
Thank-you for looking into this. I've enjoyed working with your generator so far. I hope it catches on.
Ok, I've removed the usage of ngmin until I can figure out how to get it to work with enclosures. Please don't hold your breath. Someone else is welcome to look into it.
Going back to old school array declarations of dependencies. Just look at any of the controller declarations for an example, or just look at my comment above. It's not just for controllers, of course, any Angular declaration that accepts a dependency needs to use this syntax (service, factory, etc).
It also works if I remove the enclosures and use the usual
angular.module('foo.bar', []) .configure(function(..) {...}) .controller('MyController', function(...) {...});
is there a reason not to go this route? That is, do other parts of the generator rely upon the enclosures?
It's certainly an option. It comes down to whether enclosures or not having to do the declarative syntax is more valuable. I'm curious what other people think. I could be persuaded.
Check out the latest version, 0.1.1, if you haven't yet. I added ng-annotate support, and it works great, even with enclosures.
Thanks! I'll check it out.
When I compile the sample app (which I haven't changed after the initial generation) and run it using a python SimpleHTTPServer, I get the following error:
Uncaught Error: [$injector:modulerr] Failed to instantiate module due to: Error [$injector:modulerr] Failed to instantiate module due to: Error [$injector:unpr] Unknown provider: a
If I remove the uglify step from the compile, everything works great.
Any ideas?
I really like this generator! Thank-you for creating it!