Angular4_checkbox双向绑定

前端之家收集整理的这篇文章主要介绍了Angular4_checkbox双向绑定前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
< td >< input type= "text" # Box [ ngClass]= "{'confirmBox': classFlag,'confirmBoxError': !classFlag}" [( ngModel)]= "confirmMaterial"
( paste)= "inputpaste($event)" ( keyup. enter)= "checkscan(Box.value)" placeholder= "Scan Material" ( ngModelChange)= "scanClass(Box.value)"
/></ td >
上面是一个输入框。 触发粘贴事件之后。 对应的行会选中


< td >< input type= "checkBox" ( click)= "setRowEditAble(item)" [( ngModel)]= "item.checked" /></ td >



inputpaste(e : any) {
const value = e. clipboardData. getData( 'text/plain');
this. matchMaterial( value);
}
matchMaterial(value : string) {
if ( this. handlingUnitMaterials) {
this. handlingUnitMaterials. forEach((item : any) => {
if ( item. material === value) {
console. log( item);
item.checked = true;
this. setRowEditAble( item);
// item.disableRemovedQty = false;
// item.disableReason = false;
this. clearSearch();
}
})
}
}



setRowEditAble(item : any) {
if ( item) {
// console.log(item);
item. disableRemovedQty = ! item. disableRemovedQty;
item. disableReason = ! item. disableReason;
if ( item. disableRemovedQty) {
item. removedQty = 0;
} else {
item. removedQtyInvalid = true;
}
if ( item. disableReason) {
item. reason = '';
item. removedQtyInvalid = false;
}
}
}

猜你在找的Angularjs相关文章