I have md-autocomplete
:
I think this solution is better because:
it uses a directive instead of the controller.
it is simpler than the other given directive solution.
Javascript
app.directive('closeOnEnter', function($compile) {
return {
restrict: 'A',
require: 'mdAutocomplete',
link: function(scope, element) {
element.on('keydown keypress', function($event) {
// 13: Enter
if ($event.keyCode == 13) {
var eAcInput = this.getElementsByTagName('input')[0];
eAcInput.blur();
}
});
},
};
});
HTML