我在项目中使用了angularJS select指令。
以下是示例:
模板:
<div ng-app>
<div ng-controller="Ctrl">
<select ng-model="selected" ng-options="f.name for f in friends "></select>
</div>
</div>
控制器:
function Ctrl($scope) {
$scope.friends =
[{name:'John', phone:'555-1212', age:0},
{name:'Mary', phone:'555-9876', age:0},
{name:'Mike', phone:'555-4321', age:0},
{name:'AllNames', phone:'5558-55', age:0},
{name:'Adam', phone:'555-5678', age:0},
{name:'Julie', phone:'555-8765', age:0}];
$scope.selected = $scope.friends[3];
}
以下是fiddle。
The `friends` list is list that I get from database table and it ordered as list above.
当我点击select指令时,会弹出窗口选项,其中包含可以选择的所有选项。我需要在选项窗口的列表顶部显示 AllNames 项。< / p>
知道如何实施它?
答案 0 :(得分:0)