答案 0 :(得分:1)
以下是使用转义键从输入中删除焦点的示例(我认为这是您要实现的目标) - CodePen
标记
<div ng-controller="DemoCtrl" ng-app="MyApp" ng-cloak>
<md-input-container md-theme="docs-dark" flex="">
<label>Name</label>
<input id="myInput" type="text" ng-keydown="inputKeydown($event)">
</md-input-container>
</div>
JS
(function () {
'use strict';
angular
.module('MyApp',['ngMaterial', 'ngMessages'])
.controller('DemoCtrl', DemoCtrl);
function DemoCtrl ($scope, $element) {
var myInput = angular.element($element[0].querySelector('#myInput'));
$scope.inputKeydown = function (event) {
if (event.key === "Escape") {
myInput.blur();
}
}
}
})();