Populating a select with Angular2 and Firebase

0

blz? I was starting at Angular2 and I find Firebase to be a much better backend than Backand, because in a very short time I was able to connect to Firebase. The question now is, I'm trying to popular a select but it's coming without the names. There are four items, but empty. Let's go to the HTML code

<label>Escolha a marca</label>
<select materialize="material_select" [materializeSelectOptions]="selectOptions" class="browser-default">
  <option  *ngFor="let marca of marcas | async">{{ nome }}</option>
</select>

And now a Firebase database image

Someone who already handles this to give me a help? Thanks, hugs!

    
asked by anonymous 21.11.2016 / 00:20

2 answers

0

I had this same problem, but I managed to solve it. I hope I can help you.

The component must iterate through the list defined in [materializeSelectOptions]="selectOptions". So in your case, just use [materializeSelectOptions]="tags" (which is the asynchronous array that will be traversed).

The options are:

{{brand.name}}

    
21.11.2016 / 22:50
0

But now the array is returning due. But within each tag, you have an object {logo, name}.

You need to access the target string tag. :

<option  *ngFor="let marca of marcas | async">{{ marca.nome }}</option>
    
24.11.2016 / 21:13