0

I want to dynamically change select item of a dropdown list control using Angular JS, but it does not change the view. I tried this one but no result yet!

Controller:

$scope.dischargeType = {id:0,title:''};

$scope.setSelect = function() {
  debugger;
  $scope.dischargeType = $scope.dischargeTypes[1];
  alert($scope.dischargeType.title);
  // it shows that the $scope.operationType get the value,but no changes on html
}

View:

<label class="col-sm-3 control-label">Discharge Type</label>
<div class="col-sm-9">
  <select ui-select2  data-ng-model="dischargeType" id="add-dischargeType" name="dischargeType">
    <option data-ng-repeat="item in dischargeTypes" value="{{item.id}}">{{item.title}}</option>
  </select>
</div>

Thank you indeed.

developer033
  • 24,267
  • 8
  • 82
  • 108
Discover
  • 13
  • 7

1 Answers1

0

From the code you posted... It doesn't look like you're actually calling the setSelect function in your code.

So basically you have a function made to do something, but if you never call it, it won't actually execute. Also, you may want to mention whether or not you're getting errors in the console window of chrome when you're viewing the page.

BRogers
  • 3,534
  • 4
  • 23
  • 32
  • i've removed the code that calling the function. – Discover May 26 '17 at 18:07
  • the function setSelect() calling with a button in html and the alert is raising and showing the value that i expected.also there is no error in my console. – Discover May 26 '17 at 18:08