我正在使用旧版AngularJS应用程序,目前刚升级到AngularJS 1.7.6。该应用程序使用ui-router,在angular.module().config
中,我们有一些使用$location.absUrl.
的代码
我知道$location
无法以正常方式注入到module.config中,因此我们正在使用ui-router网站上建议的$injector
。 https://github.com/angular-ui/ui-router/wiki/URL-Routing
但是,$location.absUrl
总是在标题上返回上述错误。根据AngularJs文档,Angular 1.7.6仍支持$location.absUrl
。我希望有人能指出正确的方向。
$urlRouterProvider.otherwise(function ($injector, $location){
var url = $location.absUrl();
if (url.indexOf('/admin') !== -1) {
$location.path("/admin");
}
else {
$location.path("home");
}
});