bootstrap 4 in Angular 2 dropdown not working

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

    i have used a different approach for getting drop down on collpased navbar.

    STEP 1 Add click event on navbar toggle button

    Html

        
    

    Step2: implement the function inside Navbar component.ts (Above navbar html template is used inside navbar component)

    import { Component} from '@angular/core';
        export class HeaderComponent  {
          buttontoggled:boolean:false;
    
        OnClik(){
          this.buttontoggled=!this.buttontoggled;
        }
    

    Step 3 based on the navbar toggle button click add class show(bootstrap 4) or open for previous bootstrap versions. we can use ngClass Directive for this

     

    Work flow

    Navbar toggle button will be visible when navbar geting collapsed for smaller resolutions

    by handling the button click event we can set one flag to check if the button clicked or not

    Based on this flag we will we will bind the css class show to navabr div using ngClass directive

提交回复
热议问题