<!DOCTYPE html>charset="utf-8"src="//apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"ng-app="myApp" ng-controller="myCtrl"255 的16进制是:{{hex}}自定义服务,用于转换16进制数:var app = angular.module('myApp', []);app.service('hexafy', function() {this.myFunc = function (x) {return x.toString(16);}});app.controller('myCtrl', function($scope, hexafy) {$scope.hex = hexafy.myFunc(255);});