0

I'm sending a form that has two alternatives to post, If one option is filled the second one needs to be empty.

on submit I send it to a function that its first line is check function to verify that everything as expected :

fc.check = () => {
  fc.first ? fc.a = fc.b = [] : fc.first = null;
}

Then I have a validation before the rest of the actions : if($scope.form.$valid) ...

The weird part happens when I console log $valid attribute and the form object and get both true and false:

form validation

By the way, using any setTimeout or clicking the button again is giving the expected results, which makes me think the object is not updated at time.

Any idea how should I figure it out?

georgeawg
  • 48,608
  • 13
  • 72
  • 95
  • Have you tried force validating when you make the change in the check method? $scope.form.filterObject.$validate() This should force re-validation of the field I believe – Artisan Jan 27 '20 at 14:42
  • With the Developer Console, logging of objects is different than logging of primitives. Objects references show the current value of the object which can be different from the values when the `console.log` statement was called. – georgeawg Jan 27 '20 at 15:54
  • See [console.log() async or sync?](https://stackoverflow.com/questions/23392111/console-log-async-or-sync) – georgeawg Jan 27 '20 at 16:06

0 Answers0