2016-07-29 2 views
0

Привет, я хочу прочитать параметр с текущего URL-адреса страницы angularJS. Мой URL-адрес страницы 'http://localhost:9999/ADMIN_APP_0.1/Security_Question.jsp?user_id=1' .I хочу прочитать этот user_id в Security_Question.jsp Я googled, и у меня что-то есть Маршрут в угловом, но мой стиль кода и его стиль совсем разные. И я не знаю о маршруте. Забыли пароль JSP-страница, которая звонит Вопрос страницы безопасностипараметр чтения от текущего url в угловых js и jsp

Forgot_Password.jsp 

var app = angular.module('formSubmit', []); 
app.controller('forgotController',[ '$scope', '$http', function($scope, $http) { 

    $scope.listOfSecurityQues=[]; 

    $scope.getAvailableUser = function() { 
    var loginId= { 
       "user_login" :$scope.loginid 
     }; 
     window.alert(" login ::::"+loginId); 

      var response = $http.post('loginController/loginidAvailable', loginId); 
      response.success(function(data, status, headers, config) { 

      window.location="./SecurityQuestion.jsp?user_id="+data; 

      }); 
      response.error(function(data, status, headers, config) { 
       alert("Exception details: " +data+" "+status); 
      }); 

      //Empty list data after process 
      $scope.list = []; 

     }; // end of getAvailableUser 


     Security_Question .jsp 

    var app = angular.module('formSubmit', []); 
    app.controller('forgotController', ['$scope','$http',function($scope, 
    $http) { 
      $scope.listOfUserSecurityQues = []; 

      $scope.getUserQuestions = function() 
      { 
       //here i want that URL user_id 
       var response = $http({method : 'GET', 
       url : "loginController/getUserQuestions"+user_id 
       }); 

       response.success(function(data, status, headers, config) { 
       angular.forEach(data, function(value, key) { 
         $scope.listOfUserSecurityQues.push(value); 
        }) 
       }) 
       response.error(function(data, status, headers, config) { 
       }) 
      };//end of getQuestions() 


     } ]); 

ответ

0

с помощью $ месте можно прочитать параметр URL.

app.controller('Controller', ['$scope','$http','$location', 
     function($scope, $http,$location) 
     { 
      $scope.Id=0; 

      $scope.getUserQuestions=function(){ 

        var url = $location.search(); 

         angular.forEach(url,function(value,key){ 
          $scope.Id=parseInt(value); 
          window.alert($scope.Id); 
         }) } 
Смежные вопросы