AngularJS Example:
HTML
<link rel="stylesheet" href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css">
<div ng-app>
<div ng-controller="ctrl">
<select ng-model="type">
<option val="short">short</option>
<option val="long">long</option>
</select>
<select>
<option ng-repeat="item in items" ng-if="doTest(item)">{{item.name}}</option>
</select>
</div< </div>
CSS
.short {
background-color:red
}
.long {
background-color:blue
}
JavaScript
function ctrl($scope) {
$scope.items = [{
name: 'Foo',
short: true,
long: false
}, {
name: 'Bar',
short: true,
long: true
}, {
name: 'Foobar',
short: false,
long: true
}]
$scope.doTest = function (item) {
if ($scope.type) {
return item[$scope.type];
}
return false;
}
}