我有一个简单的angularJS app搭建Yeoman。我正在尝试设置Google Calendar API,以便将其作为服务进行访问。但是,我一直在
angular.js:13294 Error: [$injector:unpr] Unknown provider:
googleApiServiceProvider <- googleApiService <- MainCtrl
我已经检查了所有可以找到的简单解决方案(该服务在app.js中被声明为依赖,拼写正确,它包含在index.html中等)但错误仍然出现。
的index.html
<script src="scripts/app.js"></script>
<script src="scripts/controllers/main.js"></script>
<script src="scripts/controllers/about.js"></script>
<script src="scripts/services/gapi.js"></script>
app.js
angular.module('mytodoApp', [
'ngAnimate',
'ngCookies',
'ngResource',
'ngRoute',
'ngSanitize',
'ngTouch',
'ngTable',
'ui.sortable',
'LocalStorageModule',
'googleApiService'
]).config(['localStorageServiceProvider', function(localStorageServiceProvider){
localStorageServiceProvider.setPrefix('ls');
}])
.config(function ($routeProvider) {
$routeProvider
.when('/', {
templateUrl: 'views/main.html',
controller: 'MainCtrl',
controllerAs: 'main'
})
.when('/about', {
templateUrl: 'views/about.html',
controller: 'AboutCtrl',
controllerAs: 'about'
})
.otherwise({
redirectTo: '/'
});
});
main.js
angular.module('mytodoApp').controller('MainCtrl', function ($scope,
$http, NgTableParams, localStorageService, googleApiService) {...}
gapi.js
angular.module('googleApiService', []).service('gapiService', function() {...});
gapi.js的内容是JavaScript quickstart guide,稍作修改。如果有人可以帮助指出我做错了什么,我将不胜感激,因为我对角度和JavaScript一般是新手。