Issue
I am new to AngularJS. Learned from W3school. Now moving forward to know how blur function and ui-event
works from other sites. So I got this code which is not working please let me know the reason or a better way to call blur function.
HTML
<div ng-app="" ng-controller="testing" >
<input ui-event="{ blur : 'blurCallback()' }">
</div>
Script tag
function testing($scope){
$scope.blurCallback = function() {
alert('Goodbye');
};
}
Solution
I suggest using ngBlur
from the AngularJS box.
This directive became available from 1.2 version of Angular.
<div ng-controller="MyCtrl">
<input type="text" ng-model="blurModel" ng-blur="onBlur($event)"/>
</div>
function MyCtrl($scope) {
$scope.onBlur = function($event) {
console.log($event);
}
}
I've attached JSFiddle example for you.
If you want to use UI.Utils
library you should inject 'ui.utils'
module to the project.
var app = angular.module('plunker', ['ui.utils']);
app.controller('MainCtrl', function($scope) {
$scope.onBlur = function($event) {
console.log($event);
};
});
<body ng-controller="MainCtrl">
<input type="text" placeholder="ui-utils" ui-event="{blur:'onBlur($event)'}"/>
</body>
This is a Plunker with ui.utils
usage.
Answered By - Artyom Pranovich
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.