2016-05-05 7 views
0

リダイレクトURLからURLに追加されたデータを取得する必要があります。以下は私のサービスです。どうすれば入手できますか?anglejsでURLデータを取得する

 paymentResponse.redirectPayment = function() { 
 
      //return $http.get(urlBase); 
 
      return $http({ 
 
        method: 'POST', 
 
        url: urlBase + redirectAPI, 
 
        headers:{ 
 
           'api_key': apiKey 
 
          }, 
 
        data: { 
 
          "type":"redirect", 
 
          "_id":"id", 
 
          "currency":"EUR", 
 
          "amount":100, 
 
          "description": "This is a test", 
 
          "result_options": { 
 
           "notification_url": null, 
 
           "redirect_url": $location.protocol() + '://'+ $location.host() +':'+ $location.port() +'#/sucessresponse', 
 
           "cancel_url": $location.protocol() + '://'+ $location.host() +':'+ $location.port() +'#/scan', 
 
           "close_window": true 
 
          } 
 
         } 
 
        }); 
 
      };

だから、今、cancleに、それは戻って私のサードパーティのAPIからリダイレクトする - と言う - "http://localhost:9000/#/scan?section_id=test_id"。

ここで、角型アプリで「section_id = test_id」を取得するにはどうすればよいですか?

+1

ためangular docsは、[この]に詳細な回答のために見てみてください(http://stackoverflow.com/questions/16964444/getting-valuesを参照してくださいあなたの

{ 'section_id': 'test_id' } 

を以下のJSオブジェクトを提供します-from-query-string-in-url-using-angularjs-location) – 92sharmasaurabh

+0

これをチェックしてください[URLからのクエリ文字列パラメータの取得方法](http://stackoverflow.com/questions/16964444/getting -values-from-query-from-url-using-angularjs-location) – 92sharmasaurabh

答えて

0

$location.search()は、すべてのクエリパラメータを持つオブジェクトを提供します。

たとえば、URLはhttp://localhost:9000/#/scan?section_id=test_idです。 $location.search()は詳細

+0

どこで行う必要がありますか?私の成功のresposneで?それは未定義の検索 – Smitha

+0

検索ありがとう、それは助け!しかし、リダイレクトURLに手動で "#"を追加するのが正しい方法であれば、私に指示してください。 – Smitha

+0

どこを使用しようとしているのか不明です。多分それは別の質問であるべきです。 – phuzi

関連する問題