<html>        
<head> <!-- www.w3tr.com -->        
<title>angular.identity Örnek</title>        
<script SRC="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>   
 <script> 
  var app = angular.module('IdentityInitialization', [])            
     app.controller('IdentityController', ['$scope', function($scope) {        
       $scope.Url = "www.w3tr.com";
       
       $scope.getURL1 = function(url) {
          return  url;
        };
       $scope.getURL2 = function(url) {
          return  url;
        };
              
       $scope.getResult = function(fn, val) {
         if (fn) {
          return fn(val);
        } else {
          return angular.identity(val);
        }
        };
        
        $scope.functionOne = function(fn, val) {
          $scope.result = $scope.getResult($scope.getURL1,$scope.Url);
        };
        
        $scope.functionTwo = function(fn, val) {
          $scope.result = $scope.getResult($scope.getURL2,$scope.Url);
        };

     }]);        
</script>        
</head>        
<body style="background-color:#ccc;" ng-app="IdentityInitialization">        
  <fieldset style="background-color:#DDE4E9;">          
    <legend>angular.identity Örnek</legend>          
<div ng-controller="IdentityController">        
<p style="font-family:Arial;color:red;background:steelblue;padding:3px;width:350px;">{{result}}</p>
  
     <input ng-model="Url">    
    <button ng-click="functionOne()">functionOne</button> 
   <button ng-click="functionTwo()">functionTwo</button>
  
      </fieldset>         
</body>        
</html>

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. //cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.2/angular.min.js