My goal is to connect my post response with a dropdown list, but the text displayed in the drop-down box shows "[object Object]". My request returns two results - `ArticleID` and `Title`. I want to display `Title` in the dropdown and save the corresponding `ArticleID` in a variable for future use. It's possible that my approach is incorrect, and I'm feeling lost.
JSON Post Response
{
ArticleID:1
Title: Raven,
ArticleID:4
Title: sam,
}
app.component.ts
ngOnInit() {
this.searchField.valueChanges
.pipe(
debounceTime(5000),
distinctUntilChanged(),
map((val) => {
this.http.post<any>('http://localhost:3000/articles/articleslistData', { pubid: '3',pubdate: "2021-01-13" }).subscribe({
next: data => {
console.log(data);
},
error: error => {
this.errorMessage = error.message;
console.error('There was an error!', error);
}
})
})
)
.subscribe();
}
app.component.html
<div class="form-field col-lg-12">
<label class="label" for="message">Headline</label>
<input id="message" class="input-text js-input" type="text" *ngFor="let Article of ArticleList
[value]="user.clientCode" [formControl]="searchField">
{{Article.Title}}
</div>