0
angular.module('myApp',[])

.controller('loginCtrl',function ($scope, $http, $rootScope, $location, $window{
$scope.login = function(loginData){

 $scope.dataLoading = true;
 $scope.loginData = angular.copy(loginData);    
 $http({
    method : 'GET',
    url : 'php/login.php',
    params: {'email' : loginData.email,'password': loginData.password,'rand' : Math.random()}
    }).then(function mySucces(response,$location){
      $scope.dataLoading = false;
        $scope.msg1 = response.data.msg1;
        $scope.msg2 = response.data.msg2;
        $scope.firstname = response.data.firstname;
        $scope.flag = response.data.flag;
        console.log($scope.flag);
        $location.url('http://localhost/timetrake/welcome.html');

    }, function myError(response) {

    $scope.user = response.statusText;

    }); 
}   
});
Abhishek Gurjar
  • 7,426
  • 10
  • 37
  • 45
Bhautik129
  • 15
  • 1
  • 5

4 Answers4

2

You can use Angular $window:

$window.location.href = 'timetrake/welcome.html';

Then

 $scope.dataLoading = true;
 $scope.loginData = angular.copy(loginData);    
 $http({
    method : 'GET',
    url : 'php/login.php',
    params: {'email' : loginData.email,'password': loginData.password,'rand' : Math.random()}
    }).then(function mySucces(response,$location){
      $scope.dataLoading = false;
        $scope.msg1 = response.data.msg1;
        $scope.msg2 = response.data.msg2;
        $scope.firstname = response.data.firstname;
        $scope.flag = response.data.flag;
        console.log($scope.flag);
        $window.location.href = 'timetrake/welcome.html';);

    }, function myError(response) {

    $scope.user = response.statusText;

    }); 
0
$location.path('/timetrake/welcome.html');

Why dont you add welcome.html into a scope route config and so u can do '/timetrake/welcome'

Giri
  • 565
  • 2
  • 9
0

Inject $location in your controller

For example

jimApp.controller('mainCtrl', function($scope, $location){

    $location.url(".....")
});
byteC0de
  • 5,153
  • 5
  • 33
  • 66
0

Try this

 $location.path('/timetrake/welcome.html');

I prefer you to use ng-route it gives you more flexibility and it maintain state for redirection and it can easily navigate by just

$state.go()
Wasiq Muhammad
  • 3,080
  • 3
  • 16
  • 29