Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 72443

Angular 1 Dropdown list values not changing when selected again

$
0
0

I have a dropdown list with city names, Dropdown1: Boston, NY, LA

Upon selected value from the dropdown list, the order of the value to be shown in the dropdown box should be changed.

If dropdown1 selected value = Boston, Then dropdown2: somethingrelated to Boston

In my code,

  1. When I selected Boston, it does change for the first time
  2. when I select another city and selected Boston again and a value for it.
  3. When I select Boston back, the dropdown box doesn't get repopulated.

Here's the code:

## RAILS VIEW

    .ui-select-input-group ng-if="statePlans.length > 0"
      select.form-control.ui-select-toggle ng-model="planOne" ng-options="plan.name for plan in statePlans track by plan.id" ng-change="changePlan()"
        option[value=""]
          | Select a Plan


## Javascript

    for (let i = 0; i < $scope.allPlans.length; i++) {
      if ($scope.allPlans[i].state == $scope.user.state) {
          statePlans.push($scope.allPlans[i]);
      }
    }
    $scope.statePlans = statePlans;

    if ($scope.user.state == 'Boston') {
      var planOne = $scope.statePlans.filter(function(item) {
        return item.name === 'Boston City Tours';
      })[0];
      $scope.planOne = planOne;
    }

Viewing all articles
Browse latest Browse all 72443

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>