$http服务和$location

1.angular的$http服务跟jquery中的ajax很类似,用法如下:

$http({
  method : 'GET',
  url : 'data.php'
  }).success(function(data,state,headers,config){
    console.log(state);
  }).error(function(data){
    console.log(data);
}); 

其中method也可以为JSONP

2.angular中的$location服务

$location下有很多方法:

bsUrl()

path()

replace()

hash()

search()

url()

host()

port()

protocol()

有些只能用去获取,有些可以获取也可以设置

原文地址:https://www.cnblogs.com/toodeep/p/4984793.html