javascript - How to enable/disable dynamic form element based on dropdown selection -


i crating form view dynamically iterating on array of field objects crating them part of model object.

xyzmodel=   [             { field: 'abc', type: 'text', displaylabel: 'abc', inputtype: 'text', isrequired: true},             { field: 'xyz', type: 'text', displaylabel: 'xyz', inputtype: 'text', srequired: true},             { field: 'mno', type: 'text', displaylabel: 'mno', inputtype: 'text', isrequired: false,},             { field: 'rsh', type: 'text', displaylabel: 'rsh', inputtype: 'text', isrequired: false, },             { field: 'lyz', type: 'drop_down', displaylabel: 'lyz', inputtype: 'text', isrequired: true, },             { field: 'def', type: 'drop_down', displaylabel: 'def', inputtype: 'text', isrequired: true, },     ] 

each module have own model object , can have different fields different name , values

i trying find solution can disable/enable fields based on drop down selected value.

this how creating form page.

<div ng-repeat="field in xyzmodel " flex="100" class="p-5" ng-switch="field.inputtype">   <md-input-container class="md-block" ng-switch-when="dropdown">     <label translate>{{field.displaylabel}}</label>     <md-select placeholder="{{field.displaylabel}}" ng-model="anothermodle[field.field]"  ng-required="field.isrequired">       <md-option ng-value="item.id" ng-repeat="item in data[field.source].data">{{item.value}}</md-option>     </md-select>   </md-input-container>   <md-input-container class="md-block" ng-switch-when="date">     <md-datepicker ng-model="vm.anothermodel[field.field]" md-placeholder="field.displaylabel" ng-required="field.isrequired">   </md-input-container>   <md-input-container class="md-block" ng-switch-default>     <label translate>{{field.displaylabel}}</label>     <input name="{{field.field}}" ng-model="vm.anothermodel[field.field]" type="{{field.inputtype}}" ng-required="field.isrequired"">   </md-input-container> </div> 


Comments

Popular posts from this blog

SVG stroke-linecap doesn't work for circles in Firefox? -

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -