答案 0 :(得分:0)
与ng-option
相同<select ng-model="selectedItem" ng-change="onChange()">
<option id="{{item.toLowerCase()}}" ng-repeat="item in someArray | filterThatIWant">{{item}}</option>
</select>
答案 1 :(得分:0)
您可以使用ng-repeat选项,
<select ng-model="selectedItem" ng-change="onChange()">
<option id="{{item.toLowerCase()}}" ng-repeat="item in someArray">{{item | filterThatIWant}}</option>
</select>
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<body>
<select ng-app="myApp" ng-controller="namesCtrl"ng-model="selectedItem" ng-change="onChange()">
<option id="{{item.toLowerCase()}}" ng-repeat="item in names">{{item | myFilter}}</option>
</select>
<script>
var app = angular.module('myApp', []);
app.filter('myFilter', function() {
return function(x) {
var i, c, txt = "";
for (i = 0; i < x.length; i++) {
c = x[i];
if (i % 2 == 0) {
c = c.toUpperCase();
}
txt += c;
}
return txt;
};
});
app.controller('namesCtrl', function($scope) {
$scope.names = [
'Jani',
'Carl',
'Margareth',
'Hege',
'Joe',
'Gustav',
'Birgit',
'Mary',
'Kai'
];
});
</script>
<p>This filter, called "myFilter", will uppercase every ODD character.</p>
</body>
</html>
请运行以上代码段