2016-04-18 21 views
0

Ich erstelle App mit angularjs. Ich brauche bestimmte Zeichenfolge von URL, hier ist meine url:Holen Sie sich bestimmte Zeichenfolge von der URL in eckigen

https://localhost:8443/#/admin/dashboard 

Ich brauche nur Admin von url

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

'console.log ($ location.path(). Split ('/') [1])' –

Antwort

0

Gerade @AvinashRaj Kommentar als Antwort einfügen.

Probieren Sie diese grundlegenden String-Methoden für Ihr Ergebnis.

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

ODER

$location.path().slice(1,6); 
$location.path().substr(1,5);