(ngModelChange) does not fire while remove all values or paste values

霸气de小男生 提交于 2019-12-09 20:19:32

问题


(ngModelChange) event does not fire while clear all values from input field by using ctrl+A or paste value

<input pInputText (ngModelChange)="IsElementDataMissingForMultiValue(languages.TranslationValue)"  
[(ngModel)]="languages.TranslationValue" type="text" />

//controller

function Controller()
{
function IsElementDataMissingForMultiValue(value)
{
alert(value)
}
}

The (ngModelChange) event triggering while removing value one by one or adding value one by one. But it does not trigger when removing all values by using Ctrl + A or pasting values by using ctrl+V.


回答1:


It's my mistake.

The problem occurred when I does not assign $event to ngModel object in some event's

This below code does not working

(ngModelChange)="IsElementDataMissingForMultiValue(languages.TranslationValue)"

But the below code working like a charm!.

(ngModelChange)="languages.TranslationValue = $event; 
IsElementDataMissingForMultiValue(languages.TranslationValue)"

I hope this may be helps others.



来源:https://stackoverflow.com/questions/45079840/ngmodelchange-does-not-fire-while-remove-all-values-or-paste-values

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!