こんにちはevryoneは角度に問題があります。私はSPAを持っています:角度コードは以下の通りです:角度ngResourceはコントローラでは機能しません
angular.module('myApp', ['ngResource']).controller('loginController',
['$scope', '$location', 'AuthService',
function ($scope, $location, AuthService) {
$scope.login = function() {
// initial values
$scope.error = false;
$scope.disabled = true;
// call login from service
AuthService.login($scope.loginForm.username, $scope.loginForm.password)
// handle success
.then(function() {
$location.path('/');
$scope.disabled = false;
$scope.loginForm = {};
})
// handle error
.catch(function() {
$scope.error = true;
$scope.errorMessage = "Invalid username and/or password";
$scope.disabled = false;
$scope.loginForm = {};
});
};
}]);
angular.module('myApp', ['ngResource']).controller('logoutController',
['$scope', '$location', 'AuthService',
function ($scope, $location, AuthService) {
$scope.logout = function() {
// call logout from service
AuthService.logout()
.then(function() {
$location.path('/login');
});
};
/*
$scope.posts = [];
$scope.newPost = {created_by: '', text: '', create_at: ''};
$scope.afficher = function(){
$scope.newPost.created_at = Date.now();
$scope.posts.push($scope.newPost);
$scope.newPost = {created_by: '', text: '', created_at: ''};
};
*/
/**
var Meetup = $resource('/api/meetups');
Meetup.query(function (results) {
$scope.meetups = results;
});
$scope.meetups = []
$scope.createMeetup = function() {
var meetup = new Meetup();
meetup.name = $scope.meetupName;
meetup.$save(function (result) {
$scope.meetups.push(result);
$scope.meetupName = '';
});
}
*/
}]);
angular.module('myApp', ['ngResource']).controller('registerController',
['$scope', '$location', 'AuthService',
function ($scope, $location, AuthService) {
$scope.register = function() {
// initial values
$scope.error = false;
$scope.disabled = true;
// call register from service
AuthService.register($scope.registerForm.username, $scope.registerForm.password)
// handle success
.then(function() {
$location.path('/login');
$scope.disabled = false;
$scope.registerForm = {};
})
// handle error
.catch(function() {
$scope.error = true;
$scope.errorMessage = "Something went wrong!";
$scope.disabled = false;
$scope.registerForm = {};
});
};
}]);
私のコードはこのような私は空白のページを取得します。しかし、もし私が['ngResource']を宣言から取り除くと、evrythingは正常に動作します。助けることができます
angular.module( 'myApp'、['ngResource'])は一度だけ使用してください。あなたの.jsで が angular.module( 'て、myApp'、[ 'ngResource']) ファイル、あなたはangular.module( 'MyApp]を')使用してモジュールをのみを必要とします。 例: (app.js) angular.module( 'myApp'、['ngResource']); MY-resource.jsで angular.module( 'て、myApp') .factory( 'myServiceという'、関数($リソース){ })。 – jcamelis
あなたの返信のためのこんにちは10q詳細に行くことができる私は角度 –