Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript AngularJS:使用动态更改下拉列表控件的选择项_Javascript_Angularjs - Fatal编程技术网

Javascript AngularJS:使用动态更改下拉列表控件的选择项

Javascript AngularJS:使用动态更改下拉列表控件的选择项,javascript,angularjs,Javascript,Angularjs,我想使用Angular JS动态更改下拉列表控件的选择项,但它不会更改视图。 我试过了,但还没有结果 控制器: $scope.dischargeType = {id:0,title:''}; $scope.setSelect = function() { debugger; $scope.dischargeType = $scope.dischargeTypes[1]; alert($scope.dischargeType.title); // it shows that th

我想使用Angular JS动态更改下拉列表控件的选择项,但它不会更改视图。 我试过了,但还没有结果

控制器:

$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
}
视图:

放电类型
{{item.title}

确实谢谢你。

从你发布的代码中。。。看起来您实际上并没有在代码中调用
setSelect
函数


所以基本上你有一个函数用来做一些事情,但是如果你从来没有调用过它,它实际上就不会执行。此外,您可能需要提及在查看页面时,chrome控制台窗口中是否出现错误。

我已经删除了调用该函数的代码。函数setSelect()在html中使用按钮调用,警报将引发并显示我期望的值。此外,我的控制台中没有错误。
<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>