<!DOCTYPE html>
<html lang="en" ng-app="myapp">
<head>
<meta charset="utf-8">
<script src="js/angular.js"></script>
</head>
<body ng-controller="myctrl">
<div>
255 的16进制是:{{hex}}<br>
255 的8进制是:{{octal}}
</div>
</body>
<script type="text/javascript">
var app = angular.module("myapp",[]);
app.service('hahaha',function(){
this.myService = function(x){
return x.toString(16);
}
this.myService2 = function(x){
return x.toString(8);
}
});
app.controller("myctrl",function($scope,hahaha){
$scope.hex = hahaha.myService(255);
$scope.octal = hahaha.myService2(255);
});
</script>
</html>