[AngularJS] Using an AngularJS directive to hide the keyboard on submit

Pleasea refer to Link

<form ng-submit="foo()" handle-phone-submit>
  <input type="text" ng-model="query" name="query" />
  <button type="submit">OK</button>
</form

 

angular.module('Foobar', [])
.directive('handlePhoneSubmit', function () {
    return function (scope, element, attr) {
        var textFields = $(element).children('input[type=text]');
         
        $(element).submit(function() {
            console.log('form was submitted');
            textFields.blur();
        document.acvtiveElement.blur();  }); }; });

 

posted @ 2016-11-08 16:39  Zhentiw  阅读(221)  评论(0编辑  收藏  举报