Finding the cause of “Unknown provider” errors

后端 未结 4 719
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-30 20:57

I\'m getting the following error:

Error: [$injector:unpr] Unknown provider: nProvider <- n

I know this is being caused by the minifi

4条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-30 21:46

    Angular 1.3.x has an ng-strict-di directive that is placed on the same element as the ng-app directive. This element causes your app to throw an error whenever dependencies have not been annotated. While it still doesn't give you the line number of the offending code, it does give you the function with its parameters (i.e. function($scope, myServiceName)) which is hopefully unique enough that you can find it pretty quickly in a good code edit.

    A good overview of the directive: ng-strict-di.

提交回复
热议问题