我创建了一个指令,当用户点击我的应用中的提交按钮时,该指令会隐藏键盘。我面临的问题仍然是如果有人点击完成或返回,它将提交表单但不会隐藏键盘。
我怎么能用我当前的指令实现这样的东西?
指令
(function() {
'use strict';
angular
.module('resonance.components.directives')
.directive('touchSubmit', function () {
return function (scope, element, attr) {
log('touchSubmit()');
var textFields = element.find('input');
element.bind('submit', function() {
log('touchSubmit() > form was submitted');
/* To dismiss onscreen keyboard */
// In some cases, focus was needed before blur to dismiss onscreen keyboard
textFields[0].focus();
textFields[0].blur();
/* To ensure status messages are visible on small screens */
$window.scrollTo(0, 0);
});
};
});
})();