1.$location服务 $location 服务,它可以返回当前页面的 URL 地址
2.$http服务 $http 是 AngularJS 应用中最常用的服务。 服务向服务器发送请求,应用响应服务器传送过来的数据。
3.$timeour服务
4.$interval服务
5.自定义服务hexafy
6.过滤器中使用自定义服务
<li ng-repeat="x in counts">{{x | myFormat}}</li>
</ul><p>过滤器使用服务将10进制转换为16进制。</p>
</div><script>
var app = angular.module('myApp', []);
app.service('hexafy', function() {
this.myFunc = function (x) {
return x.toString(16);
}
});
app.filter('myFormat',['hexafy', function(hexafy) {
return function(x) {
return hexafy.myFunc(x);
};
}]);
app.controller('myCtrl', function($scope) {
$scope.counts = [255, 251, 200];
});
</script></body>
</html>