0

i am getting the following error while routing the page using angular.js.

Error:

RangeError: Maximum call stack size exceeded
    at $ (http://oditek.in/Gofast/js/angularjs.js:73:115)
    at K (http://oditek.in/Gofast/js/angularjs.js:62:39)
    at h (http://oditek.in/Gofast/js/angularjs.js:54:410)
    at http://oditek.in/Gofast/js/angularjs.js:53:480
    at http://oditek.in/Gofast/js/angularjs.js:55:397
    at r (http://oditek.in/Gofast/js/angularjs.js:60:200)
    at x (http://oditek.in/Gofast/js/angularroute.js:6:364)
    at link (http://oditek.in/Gofast/js/angularroute.js:7:92)
    at $ (http://oditek.in/Gofast/js/angularjs.js:73:89)
    at K (http://oditek.in/Gofast/js/angularjs.js:62:39) <!-- ngView:  -->

I am explaining my code below.

index.html:

<!DOCTYPE html>
<html lang="en" ng-app="Channabasavashwara">
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>...:::WELCOME TO Channabasavashwara Institude of Technology:::...</title>

    <!-- PACE LOAD BAR PLUGIN - This creates the subtle load bar effect at the top of the page. -->
    <link href="css/pace.css" rel="stylesheet">
    <script src="js/pace.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <script src="js/angularjs.js" type="text/javascript"></script>
    <script src="js/angularroute.js" type="text/javascript"></script>
    <script src="controller/loginRoute.js" type="text/javascript"></script>
    <!-- GLOBAL STYLES - Include these on every page. -->
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href='http://fonts.googleapis.com/css?family=Ubuntu:300,400,500,700,300italic,400italic,500italic,700italic' rel="stylesheet" type="text/css">
    <link href='http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800' rel="stylesheet" type="text/css">
    <link href="icons/font-awesome/css/font-awesome.min.css" rel="stylesheet">
    <link rel="shortcut icon" href="img/favicon.png">
    <!-- PAGE LEVEL PLUGIN STYLES -->
    <!-- THEME STYLES - Include these on every page. -->
    <link href="css/style.css" rel="stylesheet">
    <link href="css/plugins.css" rel="stylesheet">
    <link href="css/chosen.css" rel="stylesheet">

    <!-- THEME DEMO STYLES - Use these styles for reference if needed. Otherwise they can be deleted. -->
    <link href="css/demo.css" rel="stylesheet">
    <!-- PAGE LEVEL PLUGIN STYLES -->
    <!-- THEME STYLES - Include these on every page. -->
    <link href="css/load.css" rel="stylesheet">
    <script src="js/jquery.min.js"></script>
    <!-- THEME DEMO STYLES - Use these styles for reference if needed. Otherwise they can be deleted. -->
    <!--[if lt IE 9]>
      <script src="js/html5shiv.js"></script>
      <script src="js/respond.min.js"></script>
    <![endif]-->
</head>

<body>
<div ng-view>
</div>
    <!-- GLOBAL SCRIPTS -->
    <script src="js/jquery.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="js/jquery.slimscroll.min.js"></script>
    <script src="js/jquery.popupoverlay.js"></script>
    <script src="js/defaults.js"></script>
    <!-- Logout Notification Box -->

    <!-- /#logout -->
    <!-- Logout Notification jQuery -->
    <script src="js/logout.js"></script>
    <!-- HISRC Retina Images -->

    <!-- THEME SCRIPTS -->
    <script src="js/flex.js"></script>
    <script src="js/dashboard-demo.js"></script>
    <script src="js/chosen.jquery.js" type="text/javascript"></script>
    <script src="js/prism.js" type="text/javascript"></script>
    <script src="js/shortcut.js"></script>
    <!-- HISRC Retina Images -->

    <!-- THEME SCRIPTS -->
    <link rel="stylesheet" type="text/css" href="calendar/tcal.css" />
    <script type="text/javascript" src="calendar/tcal.js"></script> 
    <script src="js/newbill.js"></script>
    <script src="controller/loginController.js" type="text/javascript"></script>
    <script src="controller/dashboardController.js" type="text/javascript"></script>
</body>
</html>

Here i have a login page first going to bind.When user will logged in successfully the dashboard page should display but its throwing the above error.

loginRoute.js:

var Admin=angular.module('Channabasavashwara',['ngRoute']);
Admin.config(function($routeProvider){
    $routeProvider
    .when('/',{
        templateUrl: 'dashboardview/login.html',
        controller: 'loginController'
    })
    .when('/dashboard',{
        templateUrl: 'dashboardview/dashboard.html',
        controller: 'dashboardController'
    });
})

loginController.js:

var loginAdmin=angular.module('Channabasavashwara');
loginAdmin.controller('loginController',function($scope,$http){
    $scope.user_name = ''; 
    $scope.user_pass = '';
    $scope.user_login=function(){
    if($scope.user_name==''){
        alert('user name filed should not keep blank');
    }else if($scope.user_pass==''){
        alert('password filed should not keep blank');
    }else{
        var userData={'user_name':$scope.user_name,'user_pass':$scope.user_pass};
        console.log('user',userData);
        $http({
            method: 'POST',
            url: "php/Login/login.php",
            data: userData,
            headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
        }).then(function successCallback(response){
            console.log('response',response);
            alert(response.data['msg']);
            location.href='#dashboard';
        },function errorCallback(response) {
            alert(response.data['msg']);
        });
    }
    }
});

Here i am getting the login page first.After finishing the successfully login it should redirect to dashboard page but this error is coming.Please help me to resolve this error.

satya
  • 3,508
  • 11
  • 50
  • 130

1 Answers1

1

Add $location in your controller. loginAdmin.controller('loginController',function($scope,$http, $location){

and replace location.href='#dashboard'; with $location.path('/dashboard');

Sarjan Desai
  • 3,683
  • 2
  • 19
  • 32
  • @ Sarjan : I changed but still the error is coming. – satya Oct 05 '15 at 09:50
  • Do you have proper location for all html and other file based on template URL? – Sarjan Desai Oct 05 '15 at 10:16
  • @ Sarjan : I found one issue the dashboardController.js file is calling repetedly in a loop i think this may the reason. – satya Oct 05 '15 at 10:17
  • @ Sarjan : yes, when i am writing only `hello` in partial html(`i.e-dashboard.html`) file its coming properly. – satya Oct 05 '15 at 10:18
  • i said the controller file is calling again and again in a loop. – satya Oct 05 '15 at 10:24
  • Then I think problem is related to something else...Check this: http://stackoverflow.com/questions/21356671/angular-route-infinite-loop, http://stackoverflow.com/questions/14565841/angular-js-route-causing-infinite-loop, http://stackoverflow.com/questions/16259890/angularjs-infinite-loop – Sarjan Desai Oct 05 '15 at 10:34
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/91379/discussion-between-sarjan-desai-and-satya). – Sarjan Desai Oct 05 '15 at 10:35