Friday, 13 November 2015

ng-keydown

What is ng-keydown:ng-keydown used to perform any task on keydown event..
Description of ng-keydown:ng-keydown has priority 0.Can evaluate and task on keydown event..
Syntax of ng-keydown:
<element ng-keydown="expression">

</element>
or


<input ng-keydown="expression"/>
How to Use ng-keydown/ng-keydown Example::
 Example 1:
<div ng-app="webapp">
    <div ng-controller="angularjsexampleCtlr" ng-init="mycount=1">
        <div>
            Angularjs Example of ng-keydown
             value of mycount before ng-keydown:   {{mycount}}
            <input ng-keydown="mycount=mycount+1" />
            value of mycount after ng-keydown:   {{mycount}}
        </div>
    </div>
</div>

Example 2:
<div ng-app="webapp">
    <div ng-controller="angularjsexampleCtlr" ng-init="mycount=1">
        <div>
            Angularjs Example of ng-keydown
            value of mycount before ng-keydown:   {{mycount}}
            <input ng-keydown="myfun()" />
            value of mycount after ng-keydown:   {{mycount}}
        </div>
    </div>
</div>

<script>
    angular.module('webapp', []).controller('angularjsexampleCtlr', function ($scope, $http) {
        $scope.myfun = function () {
           $scope.mycount = $scope.mycount + 1;
        }
    });

</script>

No comments :

Post a Comment