(IONIC)错误: [$injector:unpr] 未知提供程序: 数据服务提供程序 <- 数据服务<- 身份验证控
(IONIC) Error: [$injector:unpr] Unknown provider: dataServicesProvider <- dataServices <- AuthCtrl
我无法连接到我创建的自定义服务(dataService)。这是控制器代码
angular.module('auth.controller', [])
.controller('AuthCtrl',function($scope, $state, $ionicHistory, dataService) {
//some code
});
这是我的定制服务
angular.module('data.service',[])
.service('dataService', ['$http',function ($http) {
//some code
}])
我的主控制器
angular.module('wgmsApp.controllers', ['auth.controller','dashboard.controller')
.controller('MenuCtrl', function($scope, $ionicPopup, $state){
}])
我的服务.js
angular.module('wgmsApp.services', ['data.service'])
所有文件都正确包含在索引中.html
您已将服务dataService
定义为模块data.service
的一部分。
因此,为了能够在另一个模块中利用一个特定模块的服务,您需要将前者注入后者。
即
angular.module('auth.controller', ['data.service']) // inject the `data.service` module here
.controller('AuthCtrl',function($scope, $state, $ionicHistory, dataService) {
//some code
});
尝试这样使用-
angular.module('auth.controller', [])
.controller('AuthCtrl',["$scope","$state","$ionicHistory","dataService",function($scope, $state, $ionicHistory, dataService) {
//some code
}]);
希望这对您有所帮助。
相关文章:
- AngularJS-需要在index.html页面中访问来自服务的数据
- 将工厂服务数据发送到控制器,以便在视图中使用
- 控制器切换后匿名功能中的访问服务数据发生变化
- 角度:如何刷新服务数据
- 如何访问回调函数之外的异步angularjs服务数据
- 如何将指令模型绑定到异步服务数据
- 基于KendoUI网格内的服务数据的静态下拉列表值选择
- 使用$timeout等待服务数据解析
- 在使用angularjs刷新页面时,不应删除服务数据
- 在ASP.NET MVC中使用屏蔽图绑定到web服务数据
- Angular:在控制器之间共享异步服务数据
- 如何在Mozilla Firefox中获取web服务数据
- ajax GET无法工作(服务数据无法获取)
- 将服务数据保存到控制器的全局变量中
- 为什么在angular中不重置服务数据?
- 在React.js中的组件之间传递Ajax/服务数据
- Angularjs从http url中的服务数据中筛选错误
- 如何检索web服务数据并将其放置在html表中
- AngularJS服务返回数据,但在编辑时会编辑原始服务数据
- OData服务数据绑定