creativetimofficial / ct-paper-dashboard-pro-angular

8 stars 10 forks source link

Select Picker does not work with data from web service #21

Closed Sauravsam85 closed 5 years ago

Sauravsam85 commented 6 years ago

The single select does not work with the angular cycles. The data just doesn't appear in the options when I try and use a web service to populate the selectpicker list. I want that to work with the NGFor because I receive information by the web service.

I have tried with local arrays and it works for me, but not with web services.

If I inspect the control I can see it has the correct data, example:

But the dropdown shows Nothing selected and on clicking the dropdown works but the list is not shown.

I have tried adding the below to ngAfterViewInit(): if ($(".selectpicker").length != 0) { $(".selectpicker").selectpicker({ iconBase: "ti", tickIcon: "ti-check" }); } But it still does not help.

My array is defined as follows: public socialcodes: Array = [];

Data comes in this array as shown below: 0:{SocialCode: 1, SocialDesc: "1 - ABC"} 1:{SocialCode: 3, SocialDesc: "3 - XYZ"} 2:{SocialCode: 4, SocialDesc: "4 - DEF"}

Sauravsam85 commented 6 years ago

@alexandru-paduraru @timcreative @chelaruc. Please look into this. Thanks.

huadeang commented 6 years ago

i have same issue

chelaruc commented 6 years ago

@Sauravsam85 @huadeang thank you for using our product and sorry for the late response. What version do you have? Best, Ciprian

MarcosRibeiroJesus commented 5 years ago

Here works fine. Version v1.0.1 Only I need to do is put the class="selectpicker". Nothing on TS.

<div class="col-md-4">
   <label for="cliente">Cliente <span class="star">*</span></label>
      <select class="selectpicker" 
           data-style="btn btn-block" 
           [(ngModel)]="saida.cliente.codigo"
           name="codigo" 
           [disabled]="saida.codigo != null">
              <option *ngFor="let cliente of clientes.reverse()" [value]="cliente.codigo">
                  {{ cliente.nome }}
              </option>
     </select>
</div>
liderisp commented 3 years ago

Problem still persists. Without class="selectpicker" works just fine, but when you add that class it displays empty list.

Please provide script on how you load it from http request.