绑定键盘事件(尤其注意:不能用a标签,不然会失效)
<input ng-model="vm.search_text" ng-keypress="vm.enterEvent($event)" type="text" placeholder="搜索" flex>
//在控制器中如下:
var vm = this;
vm.enterEvent =enterEvent;
function enterEvent(e) {
var key_code = window.event?e.keyCode:e.which;
if(key_code==13){
console.log(11111111);
//to do something...
}
}
网友评论