Error: Unknown provider: employeesProvider <- employees

懵懂的女人 提交于 2019-11-28 10:56:28

So the problem was that I was setting up the EmployeeCtrl controller through ng-controller inside my partial's view, like so:

    <div class="viewPage" ng-controller="EmployeeCtrl">

When using resolve, however, the controller set up must be done through the router in order for it to be available at runtime. I removed the ng-controller="EmployeeCtrl...

    <div class="viewPage">

... and presto, like nothing ever happened.

I have to note that I received help from the kind, patient folks over on the AngularJS IRC channel...

Since you defined the factory called Employee, you should use the exact name to refer to this module when you inject it to the controller.

var employeeCtrl = app.controller('EmployeeCtrl', [
      '$scope',
      'employees',

Change to

var employeeCtrl = app.controller('EmployeeCtrl', [
      '$scope',
      'Employee',
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!