angularjs——过滤器中,使用自定义服务

& lt; !DOCTYPE html>

& lt; html>

& lt; head>

& lt;元charset=皍tf-8"在

& lt;元http-equiv=癤-UA-Compatible"内容=癐E=edge"在

& lt; title> & lt;/title>

& lt;链接rel=皊tylesheet"https://www.yisu.com/zixun/href=" ">

& lt;/head>

& lt; body>

& lt; div ng-app=癿yApp"在

在过滤器中使用服务

& lt; h2> {{255 | myFormat}} & lt;/h2>

& lt;/div>

& lt;/body>

& lt;脚本https://www.yisu.com/zixun/src=" http://cdn.static.runoob.com/libs/angular.js/1.4.6/angular.min.js ">

& lt; script>

应用var=angular.module (“myApp", []);

app.service (“hexafy",函数(){

。myFunc函数(x)={

返回x.toString (16);

}

});

app.filter (“myFormat", [& # 39; hexafy& # 39;函数(hexafy) {

返回函数(x) {

返回hexafy.myFunc (x);

}

}]);

& lt;/script>

& lt;/html>

 angularjs——过滤器中,使用自定义服务

angularjs——过滤器中,使用自定义服务