Reputation: 2490
I have a CATEGORY Array in my MongoDB database. i am fetching data from that and when i'm logging it on console it shows all the array data. but when i'm putting it on the template with *ngFor, it only shows the first one. why ?
this is the template :
<label for="categoryName">Category Name</label>
<input type="text" class="form-control form-control-sm" placeholder="Choose Category or Search..." name="categoryName" formControlName="categoryName" list="categorys" id="categoryName">
<datalist id="categorys" *ngFor="let category of categorys">
<option value="{{category.categoryName}}">
</datalist>
Upvotes: 2
Views: 1788
Reputation: 222582
Change it as follows, ngFor
should be on the option rather than on dataList
<datalist id="categories">
<option *ngFor="let one of categoryList" value="{{one.categoryName}}">
</option>
</datalist>
Upvotes: 7