angular2中回车键事件

<input id="idInputCrux" [(ngModel)]="productList.keyWords" (keyup)="($event.which === 13) ? getProductList() : 0" placeholder="搜索商品名称/价格/条码">

<a href="javascript:void(0);" class="search-btn" (click)="getProductList()">
<i class="icon"></i>
</a>

.screen-box .search-btn {
display: block;
float: left;
margin: 5px;
border-radius: 3px;
line-height: 32px;
height: 32px;
background-color: #ff5d49;
padding: 0 20px;
}
.screen-box .date-box .text {
float: left;
height: 32px;
line-height: 32px;
width: 30px;
text-align: center;
}

概念陈述:angularjs 1.x统称为angularJs
angular 2.0后 统称为 angular,未做特殊版本说明,文中所述皆为2.0后的版本

关于 下面这段代码新版里面已经不再支持了,新版语法参考后面的写法

<input type="text" ng-model="text1" ng-keyup="enterEvent($event)" />

这里已经替换成如下操作:

/*input的键盘事件*/
<input type="password" maxlength="20" [(ngModel)]="password" class="cla-tex" placeholder="密码"
                               name="password" (keyup)="($event.which === 13)?login('password'):0">
<input id="idInputCrux" [(ngModel)]="productList.keyWords" (keyup)="($event.which === 13) ? getProductList() : 0" placeholder="搜索商品名称/价格/条码">

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容