Javascript 从url中获取特定的字符串

Javascript 从url中获取特定的字符串,javascript,angularjs,Javascript,Angularjs,我正在使用angularjs创建应用程序。我需要url中的特定字符串,以下是我的url: https://localhost:8443/#/admin/dashboard 我只需要从url管理员 console.log($location.path())// this will gives me `/admin/dashboard` 只是粘贴@AvinashRaj评论作为答案 尝试这些基本的字符串方法来获得结果 $location.path().split('/')[1]; 或 $loca

我正在使用angularjs创建应用程序。我需要url中的特定字符串,以下是我的url:

https://localhost:8443/#/admin/dashboard
我只需要从url管理员

console.log($location.path())// this will gives me `/admin/dashboard`

只是粘贴@AvinashRaj评论作为答案

尝试这些基本的字符串方法来获得结果

$location.path().split('/')[1];

$location.path().slice(1,6);
$location.path().substr(1,5);
console.log($location.path().split('/')[1])