2016-07-29 43 views
0

嗨,朋友們,我想從 angularJS的頁面當前URL讀取參數。我的網頁網址是 'http://localhost:9999/ADMIN_APP_0.1/Security_Question.jsp?user_id=1'.I 想要在Security_Question.jsp中讀取此user_id 我使用Google搜索,並且得到了一些東西,但是我的代碼風格和樣式完全不同。我不知道路由。 忘記密碼是由使用$位置我們可以看到URL的參數調用安全問題頁面從角度js和jsp中的當前url讀取參數

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

jsp頁面。

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); 
         }) }