要啓用/禁用
<div class="btn-group">
<button [attr.disabled]="dropdownDisabled ? true : null"
type="button" class="btn btn-default dropdown-toggle"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Category <span class="caret"></span>
</button>
<ul class="dropdown-menu default-dropdown">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
</ul>
</div>
<button (click)="dropdownDisabled = !dropdownDisabled">toggle</button>
打開/關閉
我假設你正在使用的引導CSS樣式
<div class="btn-group dropdown" [class.open]="dropdownOpened">
<button (click)="dropdownOpened = !dropdownOpened"
type="button" class="btn btn-default dropdown-toggle"
data-toggle="dropdown" aria-haspopup="true"
[attr.aria-expanded]="dropdownOpened ? 'true': 'false' ">
Category <span class="caret"></span>
</button>
<ul class="dropdown-menu default-dropdown">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
</ul>
</div>
你的意思是打開/關閉或啓用/禁用? –
@GünterZöchbauer抱歉打開關閉 – Sajeetharan