ng-blur

What is ng-blur:ng-blur used to perform any task on blur (when an element has lost focus )event.
Description of ng-blur:When an element has lost his focus than this directive executed .
ng-blur has priority 0.
Syntax of ng-blur:
<element ng-focus="myfun()"></element>
Or

<div ng-focus="msg='This is angularjs example of ng-focus'"></div>
How to Use ng-blur/ng-blur Example::
Example 1:
<div ng-init="msg='angularjs example'">
    msg1:{{msg}}
    <div ng-focus="msg='This is angularjs example of ng-focus'">
        msg2:{{msg}}
    </div>
</div>
o/p: msg:angularjs example
     when ng-focus fire
     msg:This is angularjs example of ng-focus
Example 2:
<div ng-app="webapp">
    <div ng-controller="angularjsexampleCtlr">
        <div>
            Angularjs Example of ng-focus
            <button ng-focus="myfun()"></button>
        </div>
    </div>
</div>

<script>
    angular.module('webapp', []).controller('angularjsexampleCtlr', function ($scope, $http) {
        $scope.myfun = function () {
            $scope.msg = "Hey this ng-focus result.";
            alert($scope.msg);
        }
    });

</script>

No comments :

Post a comment