点击后,更改为图标:-fa-angle-down。
默认情况下,我显示的是fa-angle-up,单击时应更改为fa-angle-down。
<div class="col text-right">
<div ngbDropdown placement="top-right" class="d-inline-block">
<div id="dropdownBasic2" ngbDropdownToggle>
<i class="fa fa-angle-up fa-5x"></i>
</div>
<i class="fa fa-angle-down fa-5x"></i> <!--show me on click-->
<div ngbDropdownMenu aria-labelledby="dropdownBasic2">
<button class="dropdown-item">Action - 1</button>
<button class="dropdown-item">Another Action</button>
<button class="dropdown-item">Something else is here</button>
</div>
</div>
</div>
</div>
答案 0 :(得分:0)
使用模板变量获取返回布尔值的isOpen方法,使用该值并相应地绑定类
<div class="col text-right">
<div #myDrop="ngbDropdown" ngbDropdown placement="top-right" class="d-inline-block">
<div id="dropdownBasic2" ngbDropdownToggle>
<i [ngClass] ="Mydrop.isOpen() ==true ? 'fa fa-angle-up ' : ''fa fa-angle-down' "></i>
</div>
<div ngbDropdownMenu aria-labelledby="dropdownBasic2">
<button class="dropdown-item">Action - 1</button>
<button class="dropdown-item">Another Action</button>
<button class="dropdown-item">Something else is here</button>
</div>
</div>
</div>
</div>