I'm currently learning Angular 2 and I have a question about auto-complete functionality. I have an input field that suggests categories when searching, and when I click on one of the suggestions, it adds a new category to a list called category-tags
using JQuery.
Now, I want to store these categories in a JSON array named "categories" and post them to a database.
Here's the code for the auto-complete input:
<h6>Add category</h6>
<div class="col-lg-12 padding0">
<input [formControl]="term" autocomplete="off" type="text" class="form-control" placeholder="Type Category Name" id="product-category-input">
<div class="catsuggestions col-lg-12 padding0">
<ul>
<li (click)="addCategory()" *ngFor="let item of items | async"><a href="#!" data-catid="item.categoryId">{{item.categoryName}}</a></li>
</ul>
</div>
</div>
List where items are added:
<ul class="category-tags"></ul>
I need help in creating a JSON array from dynamically added list items. Thank you!