2

I am using bootstrap selectpicker in my angular 4 application and I have to default value to it from my type script code. These are the jquery methods given in this documentation https://silviomoreto.github.io/bootstrap-select/methods/

I want to call the methods only using angular. I have tried using ElementRef, here is my code,

 this.elementref.nativeElement.selectpicker('val',[defaultvalues])

It gives me the error "selectpicker is not a function". But logging this.elementref.nativeElement prints the "select" element as shown below.

<select _ngcontent-c4="" appselectpicker="" class="selectpicker ng-untouched
 ng-pristine ng-valid" data-live-search="true" formcontrolname="category" 
 multiple="" title="Any" tabindex="-98" ng-reflect-name="category">
      <option _ngcontent-c4="" data-tokens="Food">Food </option>
      <option _ngcontent-c4="" data-tokens="Coffee">Coffee</option>
      <option _ngcontent-c4="" data-tokens="Night Life">Night 
      Life</option>
      <option _ngcontent-c4="" data-tokens="Breakfast">Breakfast</option>
</select>
Mr.Gaja
  • 173
  • 2
  • 3
  • 12
  • Please provide the console.log output for this element. – Myonara Aug 04 '17 at 11:11
  • I have added the console.log output of the element in the question @Myonara – Mr.Gaja Aug 04 '17 at 12:40
  • bootstrap-selectpicker is a jquery plugin, so maybe you need help to [use jquery together with angular2+](https://stackoverflow.com/questions/30623825/how-to-use-jquery-with-angular). – Myonara Aug 04 '17 at 12:52
  • Ya its possible if I use jquery inside angular, but I dont want to use jquery. Is thr any way I can do this using angular only.? @Myonara – Mr.Gaja Aug 04 '17 at 13:27
  • I don't see a way to use a jquery plugin wihtout jquery. Perhaps another package like [angular-material](https://material.angular.io/components/select/overview). – Myonara Aug 04 '17 at 13:33

0 Answers0