angularjs - Why will my Javascript run fine normally, but minnified, it won't? -
this question has answer here:
- angularjs minify best practice 6 answers
i have webapp i'm developing uses front-end of html + javascript (angular 1.5.0) + css. website performs fine when run on localhost. have /index.html
file. file imports javascript code this: <script src="/app/app.js"></script>
but have implemented automated linting, uglifying etc. using grunt. grunt nicely converts single javascript file (/app/app.cs
) minnified 1 (/dist/js/app.min.js
). changed /index.html
include minnified javascript instead: <script src="/dist/js/app.min.js"></script>
. application stops working. , in browser's dev console, see following error:
angular.js:68 uncaught error: [$injector:modulerr] failed instantiate module myapp due to: error: [$injector:unpr] unknown provider: http://errors.angularjs.org/1.5.0/$injector/unpr?p0=a @ http://127.0.0.1:8080/bower_components/angular/angular.js:68:12 @ http://127.0.0.1:8080/bower_components/angular/angular.js:4397:19 @ getservice (http://127.0.0.1:8080/bower_components/angular/angular.js:4550:39) @ injectionargs (http://127.0.0.1:8080/bower_components/angular/angular.js:4574:58) @ object.invoke (http://127.0.0.1:8080/bower_components/angular/angular.js:4596:18) @ runinvokequeue (http://127.0.0.1:8080/bower_components/angular/angular.js:4497:35) @ http://127.0.0.1:8080/bower_components/angular/angular.js:4506:11 @ foreach (http://127.0.0.1:8080/bower_components/angular/angular.js:321:20) @ loadmodules (http://127.0.0.1:8080/bower_components/angular/angular.js:4487:5) @ createinjector (http://127.0.0.1:8080/bower_components/angular/angular.js:4409:19) http://errors.angularjs.org/1.5.0/$injector/modulerr?p0=raptorapp&p1=error%…f%2f127.0.0.1%3a8080%2fbower_components%2fangular%2fangular.js%3a4409%3a19)
why normal javascript file work fine, 1 minified grunt won't? how can fix it?
your angular component being minified , there no way know service inject. should decorate controllers , other pieces allow angular work properly. read on here: angularjs minify best practice
Comments
Post a Comment