| value | * |
to be returned. |
<!DOCTYPE HTML>
<html ng-app="exampleApp">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="angular.min.js"></script>
<script>
var exampleApp = angular.module(‘exampleApp‘,[]);
exampleApp.controller(‘ShowController‘,[‘$scope‘, function($scope){
$scope.result = "";
$scope.double = function(n){
return n*2;
}
$scope.triple = function(n){
return n*3;
}
$scope.answer = function(fn, val){
return (fn || angular.identity)(val);
}
$scope.show = function(){
$scope.result = $scope.answer($scope.double, 3);
}
}]);
</script>
</head>
<body>
<div id="test">博弈网络科技</div>
<div>
<div>
angular.identity
</div>
<div id="myCtrl" ng-controller="ShowController">
<input type="button" id="btn" ng-click="show()" value="answer" />
:<input type="text" id="answer" ng-model="result" />
</div>
</div>
<hr>
</body>
</html>
?原文:http://boyitech.iteye.com/blog/2169278