angular.js - select如何根据参数显示相应的选项
伊谢尔伦
伊谢尔伦 2017-05-15 17:09:49
0
1
549

我的代码如下:

<select ng-model="testV" ng-change="change()">
      <option value="">Any</option>
      <option value="0">0</option>
      <option value="1">1</option>
      <option value="2">2</option>
</select>

如何让selected的选项设置为value等于$scope.testV的项呢?

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(1)
淡淡烟草味

Add this sentence$scope.testV = 2; to the controller and it will display 2 by default.

$scope.change = function(){
    console.log($scope.testV);
}

In this way, every time the select value is changed, the console will output the changed value.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template