bootstrap 4 in Angular 2 dropdown not working

后端 未结 14 1355
旧巷少年郎
旧巷少年郎 2021-02-04 08:36

I have followed the following to install bootstrap 4 into my Angular 2 project: Accepted Answer, following the first 1,2,3 and 4 steps

However when I add the following <

14条回答
  •  無奈伤痛
    2021-02-04 09:19

    Like Andrien's said, you can simplify the code like this.

    constructor(private _el: ElementRef) { }
    
    @HostBinding('class.show') isOpen = false;
    
    @HostListener('click') toogleOpen() {
        this.isOpen = !this.isOpen;
        this._el.nativeElement.querySelector('.dropdown-menu').classList.toggle('show')
    }
    

提交回复
热议问题