Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dropdown Bootstrap 4 doesn't work in production of angular's application

I am using bootstrap 4 in my angular application, the dropdown function is working perfectly in mode developer but in production mode, I got this error:

Uncaught Error: DROPDOWN: Option "popperConfig" provided type "window" but expected type "(null|object)".
at Object.typeCheckConfig (vendors.e5434761d9d5f5d91054.bundle.js:1)
at e.t._getConfig (vendors.e5434761d9d5f5d91054.bundle.js:1)
at new e (vendors.e5434761d9d5f5d91054.bundle.js:1)
at HTMLButtonElement. (vendors.e5434761d9d5f5d91054.bundle.js:1)

and this is the code that i'am using in my application

<div class="dropdown">

  <button class="btn btn-secondary dropdown-toggle" type="button" 
    id="dropdown-search" data-toggle="dropdown"
    aria-haspopup="true" aria-expanded="false">

    Fiches consultées
  </button>

  <div class="dropdown-menu dropdown-filter filter-menu" 
    aria-labelledby="dropdown-search">

    <div *ngFor="let h of historiques" class="form-check">

      <input class="form-check-input" id="{{h.name}}" type="checkbox"
        value="{{h.name}}" [(ngModel)]="h.selected" 
        (change)="getSelected()">

      <label class="form-check-label" for="{{h.name}}">
        {{h.code}}
      </label>
    </div>
  </div>
</div> 
like image 914
boh_geek Avatar asked Jan 07 '20 12:01

boh_geek


Video Answer


2 Answers

The problem is with bootstrap 4.4+ version, change to bootstrap 4.3.1 and will works fine.

You can install it from npm and then add the path into angular.json file (styles and scripts configs):

npm install [email protected]

or use urls in your index.html

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
like image 183
Knnwulf Avatar answered Oct 20 '22 04:10

Knnwulf


We have the same issue at the moment, but only with IE11.

Update 1: As of right now I can tell you, that it hast something to do with the angular / typescript version. I reverted our app from 8.2.14 / 3.5.3 back to 8.0.0 / 3.4.3 and it starts working again. Now we will go up the different version to find out, what version change cases the problem.

Update 2: After testing multiple combinations of angular versions, we found out that these two packages caused our problem:

"@angular-devkit/build-angular"

"@angular/cli"

A newly created angular 8 project uses the follwing versions:

"@angular-devkit/build-angular": "~0.803.20"

"@angular/cli": "~8.3.20"

But with 8.3.x it´s not working! Reverting these two packages to the latest 8.2.x version fixes our problem!

"@angular-devkit/build-angular": "0.802.2"

"@angular/cli": "8.2.2"

like image 27
Mystiker Avatar answered Oct 20 '22 04:10

Mystiker