iv360TextInputChangeDelay2

HTML

<script src="http://code.angularjs.org/1.2.0/angular.js"></script>
<div ng-app="app" ng-controller="ctrl">
    <input ng-model="input" iv360-Text-Input-Change-Delay="change()">
        
        
    </input>
    Input:{{input}}
    <div ng-if="show">
        Show
    </div>
    <div ng-if="!show">
        Hide
    </div>
    
    
</div>

JavaScript

var valuationModule = angular.module('app', []);
 console.clear();
valuationModule.controller('ctrl', function($scope) {
    
    $scope.show = true; 
    $scope.change = function() {
        //console.clear();
         console.log("Called Change!!!!!!!!!!!!!!!!!!");
        $scope.show = !$scope.show;
    }
    
});
valuationModule.directive('iv360TextInputChangeDelay', ['$timeout', '$parse', function($timeout, $parse) {
	return {
		restrict: 'A',
		require: 'ngModel',
		priority: 1,
		link: function(scope, element, attrs, ngModelCtrl) {
			var	inputWaitDelay = 800,
				previousSentVal,
				timeout;
			
			if(attrs.inputWaitDelayMs)
			{
				inputWaitDelay = attrs.inputWaitDelayMs;
			}
			
			element.unbind('input').unbind('keydown').unbind('change');

			element.bind('focus', function() {
				previousSentVal = element.val();
			});
			
			element.bind('keyup', function(){
				$timeout.cancel(timeout);
				timeout = $timeout(function(){
					scope.$apply(function(){
						ngModelCtrl.$setViewValue(element.val());
						if (previousSentVal !== element.val())
						{
							previousSentVal = element.val();
					debugger;	console.log($parse(attrs.iv360TextInputChangeDelay)(scope, attrs.iv360TextInputChangeDelay));	scope.$eval(attrs.iv360TextInputChangeDelay);
						}
					});
				}, inputWaitDelay, false);
			});
		}
	};
}]);