var app = angular.module('myApp', ['ngRoute']);
app.config(['$routeProvider', function($routeProvider) {
$routeProvider.
when('/success', {
templateUrl: 'success.html',
controller: 'sucCtrl'
}).
otherwise({
redirectTo: '/index'
})
}])
app.controller('validateCtrl', function($scope, $http, $location) {
$scope.submit = function(user,password) {
//for local storage validation
$http.get('credentials.json').then(function(response) {
$scope.credentials = response.data;
if((user === $scope.credentials.username) && (password === $scope.credentials.password)){
alert("ok");
$location.path('/success');
}
else{
alert("nit "); }
});
};
})
app.controller('sucCtrl',['$scope', function($scope) {
alert("succs");
}]);
これは初心者の質問かもしれません。ログインフォームを検証し、成功時に success.html にリダイレクトしようとしています。しかし、次のページに移動できません。$location.path('/success') を使ってみました。ここにplunkerの作業サンプルがあります.. http://plnkr.co/edit/0v7njznHdtwgpaG2NfwA?p=preview