如何获取当前网址的当前协议主机和端口?
app.factory('actionTypeFactory', ['$resource', function($resource, $location){
return $resource($location.protocol() + '://'+ $location.host() +':'+ $location.port() +'82/somelocation')
}]);
我希望网址看起来像这样: http:// localhost:80 / somelocation
答案 0 :(得分:16)
您必须注入$ location服务,这就是未定义的原因:
app.factory('actionTypeFactory', ['$resource', '$location', function($resource, $location){
return $resource($location.protocol() + '://'+ $location.host() +':'+ $location.port() +'82/somelocation')
}]);