AngularJS Error: $injector:unpr Unknown Provider

后端 未结 13 857
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-13 08:10

I\'m trying to build my own service by following the example in the documentation for the factory methodology. I think I\'ve done something wrong however because I continue

13条回答
  •  囚心锁ツ
    2020-12-13 09:01

    Since this is the first Stackoverflow question that appears on Google when searching for Error: $injector:unpr Unknown Provider I'll add this here.

    Make sure that in your index.html any modules/dependencies are not being loaded after they are needed.

    For example in my code customFactory.factory.js begins like this:

    angular
       .module("app.module1")
       .factory("customFactory", customFactory);
    

    However the index.html looked like this:

        
        
    

    Where it should've really looked like this:

        
        
    

    Since customFactory.factory.js is declared as part of module1, it needs to be loaded before customFactory

提交回复
热议问题