如何在 AngularJS 示例中添加更多選擇選項,如下所示:
<div ng-app="MyApp" ng-controller="MyController">
<label>Student Class:</label>
<select id="class" name="class">
<option>C1608G</option>
</select>
<a href="#" id="add" style="color: blue;">Add class</a>
</div>
uj5u.com熱心網友回復:
您可以使用任一屬性/指令:
- 選擇元素中的ng-options
- ng-repeat在您的選項元素中
這是一個示例(假設您的 $scope 中有一個名為“options”的物件陣列):
<select id="class" name="class" ng-options="option as option.name for option in options track by option.value">
</select>
<select id="class" name="class">
<option ng-repeat="option in options">
<a href="option.address">{{option.name}}</a>
</option>
</select>
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/464224.html
