Angularjs Error: $injector:unpr Unknown Provider with using
Angularjs Error: $injector:unpr Unknown Provider with using ui-router
我得到未知的提供者错误,我不知道为什么。我的angular控制器找不到我创建的服务。我的服务定义为:
var app = angular.module('losApp');
app.service('ClientService', ['$scope','$http','$q',function($scope,$http,$q){
var client = {};//empty oject that will store multiple function
return client; //return the client object
}]);
同样,我的控制器被定义为:
var app = angular.module('losApp');
app.controller('DashboardController', ['$scope', '$modal','ClientService',function($scope, $modal,ClientService){}
在我的index.html中,脚本标签声明如下:
<script src="js/app.js"></script>
<script src="js/services/ClientService.js"></script>
<script src="js/controllers/DashboardController.js"></script>
在app.js中,我使用ui-router模块来处理应用的路由。
var app = angular.module('losApp', ['ngMessages', 'ui.bootstrap', 'angularFileUpload', 'ui.router', 'summernote', 'angucomplete-alt', 'ngCookies']);
app.config(function($stateProvider,$urlRouterProvider,$locationProvider, $interpolateProvider){
$urlRouterProvider.otherwise('/'); //redirects to this page is
$stateProvider.state('/',{
url:'/',
views : {
// the main template will be placed here (relatively named)
'':{
templateUrl: '/js/pages/dashboard.html',
controller: 'DashboardController'
}
}
});
});
在浏览器控制台日志中,点击angular错误信息。此外,我按照angularjs
医生的建议,但仍然没有成功。
我做错了什么,提前感谢。
我发现为什么我得到未知的提供者。这是因为我把$scope对象注入了工厂,这是不允许的。
相关文章:
- Fighting with FRP
- issue with FB.Event.subscribe
- 迷你$provider注入茉莉花和角
- geolocation-marker.js conflict with markerclusterer.js
- Angular 2.0 with JavaScript or TypeScript?
- 为什么不推荐使用“with”?是否有更好或其他方法可以“下降”到对象的命名空间
- WebComponentsJS with IE10
- 指令的模板必须只有一个根元素:With restrict E&替换true
- timeago.js with datatable and PHP
- Ajax and Json with Rails
- errors with Javascript try catch
- how to split a string with ','
- Understanding Javascript scope with "var that = this&qu
- Architecture for CPU intensive tasks with NodeJS & Socke
- How to declare a Map containing certain properties with flow
- 设置'这'在React with Inverse Data Flow中
- Unit-testing multiple use cases with Karma & Mocha.js
- Google Provider Login with Firebase and Ionic
- Angularjs Error: $injector:unpr Unknown Provider with using
- AngularJS with Karma Unknown provider: $routeProvider