1
我做出了榜樣plnkr這裏:Plnkr展開/收起多選擇標籤(OPTGROUP)
我想知道是否有可能作出大膽的標籤展開/摺疊的?我問,因爲我一直在想如何做到這一點,我只看到大膽的標籤,並擴大我看到他們的內容。
下面是HTML代碼,JS和CSS
HTML:
<!DOCTYPE html>
<html ng-app="test">
<head>
<script data-require="[email protected]" data-semver="1.4.1" src="https://code.angularjs.org/1.4.1/angular.js"></script>
<link rel="stylesheet" href="style.css" />
<script src="script.js"></script>
</head>
<body ng-controller="MainCtrl">
<select multiple class="box">
<optgroup ng-repeat="(key,value) in data" label="{{value.label}}">
<option ng-repeat="id in value.ids">{{id}}</option>
</optgroup>
</select>
</body>
</html>
JAVASCRIPT:
// Code goes here
var app = angular.module('test',[]);
app.controller('MainCtrl',function ($scope) {
$scope.data = [{
label: "My Label", ids: [ "one id", "another id" ]
},{
label: "My Other Label", ids: [ "one id", "another id" ]
}];
});
CSS:
.box {
height: 120px;
}
你真棒!我不是爲什麼我沒有想到這一點 –
我會包括ng-class =「{'glyphicon glyphicon-chevron-right':value.expanded,'glyphicon glyphicon-chevron-down':!value.expanded 「在optgroup裏面? –
好吧,這不是問題的一部分,但你可以使用新的變量來添加CSS或任何你想要的 –