Z
Z
Zakharov Alexander2017-04-27 11:23:46
JavaScript
Zakharov Alexander, 2017-04-27 11:23:46

Angular 1.6.4 $watchGroup returns empty strings for old values. I don't understand what's wrong?

Actually, all the old values ​​are returned empty and I can’t find out what happened before (pasting into the input form fields is performed from the clipboard): However, after a while after several changes in the fields in manual mode (by pressing keys on the keyboard), everything returns to normal and the old values ​​are already specified normally. If I enter everything manually at once, without using the clipboard, then everything seems to be normal. $watchCollection gives correct results. Here all the old values ​​are specified correctly. ??? There are absolutely no ideas what is wrong.
d57625cbe7ce464285738e4771d7c6b5.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Oleg Drapeza, 2017-04-27
@SuperOleg39ru

I recommend that you abandon $watchGroup and $watch, instead add ng-change to the inputs, and do whatever you want in the handler functions.
Reasons:
1) Full control of the process
2) No performance loss due to watch'ers

N
Nicholas, 2017-04-27
@healqq

What for in principle watchCollection? Do you have ng-model there? Use ng-change. Well, all sorts of convenient buns for working with forms, since angular is fine with this.
Well, the problem is not in the watchCollection, I threw in the minimum option here - everything works:
plnkr.co/edit/YOaCVdKyav5Q9OuXxY8B?p=preview

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question