我正在尝试获取一个选择下拉列表,以按团队名称对一些团队进行排序。它似乎部分工作,但似乎无法让团队按顺序显示。真的很想把“所有团队”放在首位,但我不知道这有多可行。
这是代码:
HTML
<div ng-app>
<div ng-controller="Ctrl">
<label>Filter by Team:</label>
<select ng-model="filters.teamIdSelected" ng-options="value.teamId as value.teamName for (key, value) in teams | orderBy: 'teamName'"></select>
</div>
JS
function Ctrl($scope) {
$scope.filters = {};
var teams = [{
"teamName": "Cubs",
"teamId": 51
}, {
"teamName": "Bulldogs",
"teamId": 68
}, {
"teamName": "Grizzlies",
"teamId": 12
}, {
"teamName": "Tigers",
"teamId": 71
}, {
"teamName": "Braves",
"teamId": 16
}, {
"teamName": "Cowboys",
"teamId": 24
}, {
"teamName": "Monsters",
"teamId": 70
}, {
"teamName": "Brats",
"teamId": 23
}, {
"teamName": "Chumps",
"teamId": 21
}, {
"teamName": "Dingleberries",
"teamId": 93
}, {
"teamName": "Redskins",
"teamId": 22
}, {
"teamName": "123Myteam",
"teamId": 47
}, {
"teamName": "Gophers",
"teamId": 87
}, {
"teamName": "Peanuts",
"teamId": 77
}, {
"teamName": "Bloopers",
"teamId": 79
}, {
"teamName": "Losers",
"teamId": 88
}, {
"teamName": "Marlins",
"teamId": 84
}, {
"teamName": "Ear Muffs",
"teamId": 75
}, {
"teamName": "Pizzas",
"teamId": 78
}, {
"teamName": "Weiners",
"teamId": 74
}, {
"teamName": "Bills",
"teamId": 86
}];
teams.unshift({
teamId: 0,
teamName: 'All Teams'
});
$scope.teams = teams;
$scope.filters.teamIdSelected = 0; }
这是一个要演示的小提琴。
提前致谢。