mercredi 28 octobre 2015

conflict in triggering span click and watch events sequences in text box and check box models in Angularjs application

I am making watch on Text box and Check box models to call my custom defined function. As I don't want to call my custom function inside the watch during initial loading of data, inside watch I am depending on a needwatch flag when to call my custom defined function. For this purpose I have kept both check box and Text boxes inside span element and when span is clicked I am making that needWatch flag to be true so that, the custom function will be called when that particular model is changed, so that this custom function won't be called during initial loading of data. This logic working fine for Text box, (even for select drop down) but failing on check box.

The reason is, for Text box, ALWAYS, its span ng-click event is triggering first and then the watch function on the Text box model is firing up next. Where as for Check box, randomly, its watch function is triggering first and then its span ng-click event is firing up next and vice versa.

I want for check box also, ALWAYS, its span ng-click event to be triggered first instead its model watch function. Is it possible?

please find the plunker and try to change text box and check box values.




Aucun commentaire:

Enregistrer un commentaire