javascript - How can I completely exit from inside a .forEach that is inside a function -


i have method:

    wordformdirty = (): boolean => {     var self = this;     angular.foreach(self.word.wordforms, function (wf, key) {         var wordformngform = 'wordformngform_' + wf.wordformid         if (!self[wordformngform].$pristine) {             return true;         }     });     return false; }; 

from see never returns true. can give me advice how can implement form that's not pristine make wordformdirty() method return true.

can try this, in case, if i've undestand issue, first time there value true result set true otherwise remains false

wordformdirty = (): boolean => {     var self = this;     var result = false;     angular.foreach(self.word.wordforms, function (wf, key) {         var wordformngform = 'wordformngform_' + wf.wordformid         if (!self[wordformngform].$pristine) {             result = true;         }      });     return result; }; 

Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -