formly-js / angular-formly

JavaScript powered forms for AngularJS
http://docs.angular-formly.com
MIT License
2.23k stars 406 forks source link

model stops updating properly using ng-click/onClick event in templateOptions #727

Closed CodeLiftSleep closed 7 years ago

CodeLiftSleep commented 7 years ago

I have some pretty involved code we are using at my job and it involves the hiding and showing of multiple sections of code utilizing some complex logic. my ng-click in one of the templates looks like this:

ng-click ="$scope.model.hidePOSProv = !$scope.model.hidePOSProv; $scope.model.showLookup = true"

and it works, however at some point in the code it stops working properly.

The issue is strange because when I set breakpoints on the code(when I take it out of the ng-click event inline and put it in a controller function on the field) it updates the model in the $scope and I see the value has changed, but then it doesn't actually update the model.

ShowLookup remains false no matter how many times I click on it, even while the hidePOSProv value changes on every click. I'm not sure if anyone else has experienced this but it is a mystery to me as to why it only happens sometimes and not others. We use formly for all our work related forms and this is the first time its happened to me today, once I added in some extra hide/show complexity to support some other things we needed to do.

Truth be told I am not sure if its a formly issue or an angular issue, because I have no desire of building a comparably complex form in just angular by itself just to find out. I am not able to give the example I am using at work because its proprietary code and there is no way I would be able to reproduce this sufficiently in a plunker. So I am kind of at a loss as to how this could be tested/reproduced.

Best I can say is this occurs when multiple hide/shows are called from different sections of code and at some point the model stops updating

CodeLiftSleep commented 7 years ago

UPDATE: Found it is happening because other expressions are executing after these and have conflicting settings and some bad logic...glad I found that out...was worried something was broke!! All is good after I corrected the logic mistake...