javascript - Parse.com + AngularJS ngRoute - route on log in -
i want spa redirect user /home after logging in. first click on log in
logs in user. second click - redirects. should happen on first click.
if rid of user.login() code , promise, redirection works first time. why that?
myapp.controller('logincontroller', ['$scope', '$location', function($scope, $location) { $scope.message = 'login page!'; $scope.update = function(usr) { user.login(usr.name, usr.password) .then(function() { $location.path('/home'); }, function(err) { alert(err.message); })} }]);
button code:
<button ng-click="update(usr)">log in</button>
i tried putting $location code in then-operation(just in case) didn't work.
edit: kinda got working. not suggested gave me idea. still, i'm reading events in angularjs @ moment. , see if come closer idea - promise.
$scope.gohome = function() { $location.path('/home'); };
and button:
<button ng-click="gohome()" ng-mousedown="update(usr)">log in</button>
edit 2: in case having same problem, found 2 questions on matter. first explains why rerouting doesn't work in parse promise , how make work, second has useful info:
Comments
Post a Comment