我正在尝试以编程方式切换bootstrap崩溃,这是
<div class="panel-heading" role="tab" id="headingStores">
<h4 class="panel-title">
<span class="collapsed" id="StoresPanel" role="button" data-toggle="collapse" data-parent="#filter-field-container" href="#filterStores" aria-expanded="false" aria-controls="filterStores">
<i class="fa fa-chevron-circle-right"></i><i class="fa fa-chevron-circle-down"></i> Stores
<span ng-if="showStore" class="pull-right">{{countStore}}</span>
</span>
</h4>
</div>
我的角度代码是
var domElement = document.getElementById('StoresPanel');
angular.element(domElement).collapse('show');
但崩溃(&#39; show&#39;)没有调用切换功能。请帮助!
答案 0 :(得分:3)
有点晚了但是,我正在使用bootstrap的崩溃组件(不是角度ui引导程序)并想从我的angular1控制器控制它,那么你可以这样做(jQuery需要加载):
const el = document.querySelector(target);
if (!angular.element(el).hasClass('in')) { // hidden
$(el).collapse('show');
}