angularjs - Using ng-required vs required -


i have following multi select box:

<select      multiple="multiple"      data-ng-model="rightselected"      data-ng-options="slide slide.slidebarcode slide in form.slides"      data-ng-required="form.slides.length > 0"  /> 

in controller @ initialization:

$scope.form.slides = []; 

i want element of form valid if there slides in slide array. these added dynamically- it's kind of slide bucket users can add slides to.

but i'm not getting how ngrequired stuff works... if change data-ng-required="true" form looks okay, of course doesn't want. if use form.slides.length > 0 checking want, not not work, messes form structure, 1 of elements vanishes seemingly @ random.

what proper way use this? docs pretty sparse on one.

check out post:

what difference between required , ng-required?

from think you're trying do, think you're using ng-required attribute wrong. ng-required attribute when want conditionally require input or not. i'm guessing in case want input required.

as per comments, if don't want manage functions, put of these in 1 function

$scope.isformvalid= function(){     if (form.slides.length > 0 && myform.$valid)         return true; } 

and

ng-disabled="isformvalid()" 

this may not elegant solution works. let me know if that's not wanted.


Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

c++ - Correct method for redrawing a layered window -

java.util.scanner - How to read and add only numbers to array from a text file -