首页 > 其他 > 详细

angular.identity

时间:2014-12-23 02:25:53      阅读:194      评论:0      收藏:0      [点我收藏+]
angular.identiy
描述:
返回它第一参数的函数. 此函数多用于函数是编程.
使用方法:
angular.identity(value);
参数详解:
Param Type Details
value *

to be returned.

返回值:
传入的value
实例代码:
<!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>
?

angular.identity

原文:http://boyitech.iteye.com/blog/2169278

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!