0
我正面臨以下問題,同時將ngResource
模塊加載到loginService
。在angularjs中加載ngResource時遇到問題
Error message: Unknown provider: $ngResourceProvider <- $ngResource <- loginService
以下是我的代碼。請幫忙。 預先感謝您。
App.js
var app=angular.module('exampleApp', ['ui.router']);
app.config(function($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise('/login');
$stateProvider
.state('login',{
url:'/login',
templateUrl:'login.html',
controller:'loginController'
})
.state('dashboard',{
url:'/dashboard',
templateUrl:'dashboard.html'
});
});
app.controller('loginController',['$scope','loginService', function($scope,loginService){
$scope.signin=function() {
loginService.authenticate($.param({username: $scope.username, password: $scope.password}),function(authenticationResult){
var authToken = authenticationResult.token;
$rootScope.authToken = authToken;
console.log('token ::'+authToken);
});
}
}]);
app.service('loginService', ['$ngResource', function($scope,$resource){
return $resource('http://localhost:7001/springangulardemo:action', {},
{
authenticate: {
method: 'POST',
params: {'action' : 'authenticate'},
headers : {'Content-Type': 'application/json'}
},
}
);
}])
你包括角resource.js添加
ngResource
?其解決方案爲 –