问题
(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