angularjs - How to conditionally assign value to a ViewModel property from within the View -


i have following html shows error message when ng-show conditions met. however, ng-init assignment happens whether error message shown or not.

<div ng-show="peopleworksform.submitted && formdata['disclosurequestion'+($index+1)+'answer'] == 'true' && formdata['disclosurequestion'+($index+1)+'optionalanswer'] == undefined"       ng-init="$parent.answervalfailed = true">    invalid value </div> 

what want operation inside ng-init after ng-show conditions met. there easy way so?

use ng-if , inside use ng-init :)

    <div class="pw-form-inline-error" ng-if="peopleworksform.submited && formdata['disclosurequestion'+($index+1)+'answer'] == 'true' && formdata['disclosurequestion'+($index+1)+'optionalanswer'] == undefined">             <span ng-init="$parent.answervalfailed = true">                             invalid value               </span>     </div> 

hope helps :)


Popular posts from this blog