bootstrap 4 in Angular 2 dropdown not working

后端 未结 14 1235
旧巷少年郎
旧巷少年郎 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:26

    You will need to add a dropdown directive in order for this to work. The directive looks like this:

    import { Directive,HostListener,HostBinding } from '@angular/core'; 
    @Directive({
    selector: '[appcustomdropdown]'
    })
    export class CustomdropdownDirective {
    
    constructor() { }
    
    @HostBinding('class.open') get opened()
    {
    return this.isOpen;
    }
    @HostListener('click') open()
    {
    this.isOpen=true;
    }
    @HostListener('mouseleave') close()
    {
    this.isOpen=false;
    }
    private isOpen=false;
    }
    

    Then, you will add the attribute like so:

提交回复
热议问题