标签: angularjs angular-ui-router
例如,如果我有这种网址localhost/About,localhost/Projects,localhost/Photography,我怎样才能获得localhost/之后的值,即About { {1}} Projects?
localhost/About
localhost/Projects
localhost/Photography
localhost/
About
Projects
我写了我的app.js如下:
Photography
答案 0 :(得分:1)
如果你需要在控制器/服务/指令中获取当前路径,$location.path()应该这样做(你需要注入$location)。
$location.path()
$location
Angular docs on $location