javascript - AngularJS: Watch form for input change on blur -
i searched many times , haven't found answer or right solution me. wanna create directive control form input change on blur. editing user settings inside tool.
so user clicking inside input field form called 'generall', until here nothin should happen, if user editing (typing) nothin should happen. user clicks outside (blur) field, directive should call function 'updatesettings' , give them form name (generall) , name + value fields.
could var vars = { formname: 'generall', fields: {allfields} }
.
i tried allready function:
return { require: "form", link: function(scope, element, attrs){z var cb = $parse(attrs.formonchange); element.on("change", function(){ cb(scope); }); } };
here code: https://plnkr.co/edit/krjtjvcs9kxrckmh3mv6?p=preview
use
element.on("blur",function(){})
sample directive
app.directive("mydirective", function ($rootscope) { return { controller: function ($scope) { }, //end of controller restrict: 'a', // element must have ng-model attribute. require: 'ngmodel', link: function ($scope, ele, attrs, ngmodel, $rootscope) { ele.on('blur', function () { //write functionality here }); }, //end of link function } //end of return }); //end of mydirective
Comments
Post a Comment