案例:AngularJS案例     状态:可编辑再运行    进入横版
x
 
1
<!DOCTYPE html>
2
<html>
3
<head>
4
<meta charset="utf-8">
5
<script src="/js/angular.js1.4.6/angular.min.js"></script>
6
</head>
7
<body>
8
<div ng-app="myApp" ng-controller="myCtrl">
9
10
<p>255 的16进制是:</p>
11
12
<h1>{{hex}}</h1>
13
14
</div>
15
16
<p>自定义服务,用于转换16进制数:</p>
17
18
<script>
19
var app = angular.module('myApp', []);
20
21
app.service('hexafy', function() {
22
    this.myFunc = function (x) {
23
        return x.toString(16);
24
    }

 运行结果 
 北美留学生论坛