`
boyitech
  • 浏览: 84106 次
  • 性别: Icon_minigender_1
  • 来自: 南通
社区版块
存档分类
最新评论
阅读更多
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>
 
0
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics