I am using angular 4 and spring boot,i get all the record as a List from spring boot to angular 4 but in the angular form i get only single object data,how to list multiple values in Search box?
component.ts: In this component i am getting all the values but display single data!
characters=[]; chars=[];
ngOnInit() {
this.drugservice.getval().subscribe(
data => {
this.chars.data,
this.characters = [
{value: data[0].id},
{label: data[0].name}
],
alert(data[0].name)
},
err => {
console.log('Error Occured ');
});
}
ang.html:
<div class="col-sm-12 col-xl-4">
<ng-select [ngClass]="'ng-select'" [options]="characters" formControlName="selectedCharacter"></ng-select>
</div>
Back end rerun Object Values:
[
{
"id": 1,
"name": "ak"
},
{
"id": 2,
"name": "java"
}
]
<select>, or you only want to show the first result? Additionally, since your problem is frontend related, you don't need the spring-boot tag (even though the data may come from a Spring boot application).data => { this.chars.data, this.characters = [ {value: data[0].id}, {label: data[0].name} ], alert(data[0].name) },means nothing.