ユーザーが正しいユーザー名とパスワードを入力したら、別の場所にリダイレクトします。しかし、$location.path('dashboard')
ここで使用すると、ブラウザーの URL が変更されましたが、そのページは読み込まれません。ctrl+R を使用してページを更新するか、ブラウザーの更新アイコンをクリックすると、適切なページが読み込まれます。
$http.post('/login', $scope.userInfo)
.success(function (data) {
//Check if the authentication was a success or a failure
//Successful POST here does not indicate success of authentication
if (data.status === "authentication success") {
//Proceed to load the dashboard for the user
$location.path('/dashboard');
} else if (data.status === "authentication error") {
//Inform user of the error
$scope.errorMessage = data.error;
$scope.showErrorMessage = true;
}
})
.error(function (error) {
$scope.errorMessage = "Error while attempting to authenticate. Check log.";
$scope.showErrorMessage = true;
});
};
}]);