problem with check box and Text box span click and watch events sequence

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    demo  and try to change text box and check box values.
Too SmartAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

F IgorDeveloperCommented:
I cannot get it triggering watch after click in checkbox, but if you need to ensure it's triggered after click,
you can modify the event timing aplying some small delay using window.setTimeout()

 $scope.$watch('checkboxModel', function(chkbxMdl) {
        if(needWatch == true){
            window.setTimeout( function(){
                 alert('Watch  on Check Box ' + needWatch);
                // call Custom Fn
            },100); //greater value triggers after
        }
      
     }, true); 

Open in new window


See http://plnkr.co/edit/QeGLOUT89Cv4v2tzfgYg?p=preview
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Too SmartAuthor Commented:
I don't know its problems but it seems your solution is working fine.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Angular

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.