angular.js - How select displays the corresponding options based on parameters
伊谢尔伦
伊谢尔伦 2017-05-15 17:09:49
0
1
576

My code is as follows:

<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>

How to set the selected option to an item with value equal to $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