簡體   English   中英

如何使用angular.js獲取URI組件

[英]How can I obtain URI components using angular.js

如何在AngularJS中獲取URI組件? 例如我有http://domain.com/photo/1

那么如何將第二個段(= 1)轉換為角度變量呢? 謝謝。

您不需要Angular,只需執行以下操作:

var url = document.URL.split('/'); // Get the current full url, eg: http://domain.com/photo/1 splitted by slashes
var lastArg = url[url.length];     // Get the last string after the last slash

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM