The problem happens because your change the array 'attributes' in your 
function *handleConfig*, so the first criteria doesn't have anymore the 
original array with the selectedAttribute, so it is reseting the combo from 
attributes. For example if I select config 'daemonumask', the attribute 
returned would be 'umask' and if I select 'fsck_configuration' the 
attribute returned would be 'AUTOFSCK_DEF_CHECK'. Your are setting to the 
array 'attributes' the new value and ignoring the old one, because all your 
combos of attributes are using the same array.

One solution would be to set your 'attributes' array inside your 
selectedConfig of your criteria. Something like this in the function 
*handleConfig: $scope.criteria.selectedConfig.attributes = 
config[selectedConfig];*And in your html inside the ng-repeat of 
attributes: *attribute for attribute in criteria.selectedConfig.attributes*

I hope that this solution helps :)


On Friday, January 8, 2016 at 12:22:51 AM UTC-2, Pradeep Kumar wrote:
>
> I am having a requirement to create a search query of parameters and send 
> it to server. I have created the drop downs from where the user will 
> populate the values. 
>
>      Below is the code on the UI: ( I am working with Angularjs 1.4.7)
> <div ng-repeat="criteria in criterias">
>                     <div class="m-b">
>                       <div class="form-group s-b" style="width: 150px;">
>                         <span>classification</span>
>                         <select 
>  ng-model="criteria.selectedClassification" class="form-control" 
> id="classification" ng-options="classification for classification in 
> classification" ng-change="handleClassification(criteria)" 
> style="max-width:100%"></select>
>                       </div>
>                       <div class="form-group s-b" style="width: 150px;">
>                         <span>Config</span>
>                         <select id="config" 
> ng-model="criteria.selectedConfig" ng-options="config for config in config" 
> class="form-control" ng-change="handleConfig(criteria)" 
> style="max-width:100%" ></select>
>                       </div>
>                       <div class="form-group s-b" style="width: 150px;">
>                         <span>Attribute</span>
>                         <select id="attribute" class="form-control" 
> ng-options="attribute for attribute in attributes" 
>  ng-model="criteria.selectedAttribute" style="max-width:100%;" 
> ng-change="handleAttrChange(criteria  )"></select>
>                       </div>
>                       <div class="form-group s-b" style="width: 150px;">
>                         <span>Predicate</span>
>                         <select class="form-control" 
> ng-model="criteria.predicate"  style="max-width:100%">
>                           <option value="matches">Matches</option>
>                           <option value="not-matches">Not Matches</option>
>                         </select>
>                       </div>
>                       <div class="form-group s-b" style="width: 100px;">
>                         <span>Value</span>
>                         <select class="form-control" name="account" 
> ng-model="criteria.value" ng-options="item for item in values" 
> style="max-width:100%">
>                         </select>
>                       </div>
>                       <div class="form-group s-b" style="margin-top: 
> 20px;">
>                         <span>
>                         <button class="btn btn-sm btn-primary pad-btn" 
> type="submit" ng-click="addCriteria()"><i class="fa fa-plus"></i>
>                         </button>
>                         <button class="btn btn-sm btn-danger pad-btn" 
> type="submit" ng-click="deleteCriteria(criteria)"><i
>                                 class="fa fa-minus"></i></button>
>                         </span>
>                       </div>
>                     </div>
>                   </div>
>
> I have wrapped the code inside a repeat so that the user can create 
> multiple criteria (each having one filter condition). The user can create 
> criteria by clicking on the `+` icon. I am facing issues when working with 
> one criteria, any update done on the config is setting the attributes of 
> all the criteia instead of the current criteria.
>
> I have created a working plunker to demo this. Please let me know where I 
> am going wrong.
>
> Link to Plunker - Plunker 
> <http://plnkr.co/edit/HETrCeWXr8AdqdIQDjf1?p=preview>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to