How to go next page after login successfully using angularJs? -
i have restful api login has written in "laravel php". have use restfull api angularjs. , after getting login response, new page should open, doing using "ngroute", not able properly.
can tell how can this.
here code:
var qaapp = angular.module('qaapp', ['ngroute', 'emoji', 'ngsanitize']); //route provider 1 page page qaapp.config(function($routeprovider , $locationprovider) { $routeprovider. when('/', { templateurl: 'login.html', controller: 'loginctrl' }). when('/login', { templateurl: 'qa.html', controller: 'askbyctrl' }). otherwise({ redirectto: '/' }); });
login controller:
function loginctrl($scope, $http, $location){ // create blank object hold our form information // $scope allow pass between controller , view $scope.formdata = {}; //login function $scope.login = function() { var request = $http({ method: 'post', url: server + 'api/login', data : $.param($scope.formdata), headers : { 'content-type': 'application/x-www-form-urlencoded' } }); request.success(function(data, status, headers, config) { alert(data.error+' '+data.description); /*console.log(data);*/ $scope.response = data; }); };
please tell me how can this.
did try add $window.location.href = 'your.address.com'; in .success ?
request.success(function(data, status, headers, config) { alert(data.error+' '+data.description); /*console.log(data);*/ $scope.response = data; $window.location.href = 'your.address.com'; });
Comments
Post a Comment