Search code examples
angularbootstrap-4angular5bootstrap-selectbootstrap-selectpicker

Cannot read property 'Constructor' of undefined on bootstrap-select v1.13.0-beta


I'm using angularJS 5 and boostrap 4. Then I added Bootstrap-select v1.13.0-beta to app from here. Bootstrap-select v1.13.0

I have also made sure that jQuery is being loaded before Boostrap-select.js enter image description here

<form  [formGroup]="userRegform" novalidate>
<fieldset class="form-group">                        
  <select class="form-control selectpicker" name="testtype" formControlName="testtype" data-live-search="true">
    <option>a</option>
    <option>b</option>
    <option>c</option>
 </select>
</fieldset>
<button type="submit">Next</button>
</form>

Solution

  • If you intend to use bootstrap-select in Angular for anything more than a very basic use case, I would highly recommend you take steps to wrap it in an angular directive.

    While it is not using the latest v1.13.0-beta, I have an example project demonstrating use of bootstrap-select within angular using bootstrap4: https://github.com/braheem/angular-bootstrap-select

    If you are adamant about using v1.13.0-beta of bootstrap-select, you can try a similar approach as done in the linked project, but swap out the version of bootstrap-select with the beta version you are using.