Angularjs minify best practice

前端 未结 7 1506
孤独总比滥情好
孤独总比滥情好 2020-11-22 03:12

I\'m reading http://www.alexrothenberg.com/2013/02/11/the-magic-behind-angularjs-dependency-injection.html and it turned out that angularjs dependency injection has problem

7条回答
  •  死守一世寂寞
    2020-11-22 03:41

    Use Strict Dependency Injection to Diagnose Problems

    With Implicit Annotation, code will break when minified.

    From the Docs:

    Implicit Annotation

    Careful: If you plan to minify your code, your service names will get renamed and break your app.

    You can add an ng-strict-di directive on the same element as ng-app to opt into strict DI mode.

    
    

    Strict mode throws an error whenever a service tries to use implicit annotations.

    This can be useful to determining finding problems.

    For more information, see

    • AngularJS Developer Guide - Using Strict Dependency Injection
    • AngularJS ng-app Directive API Reference
    • AngularJS Error Reference - Error: $injector:unpr Unknown Provider

提交回复
热议问题