I am facing an issue with JSON data as I have 3 tables in my database named "dictionary" with the same structure but different column names:
{"id":1,"test_1":"test"},{"id":2,"test_1":"lalala"} - first JSON
{"id":1,"test_2":"****"},{"id":2,"test_2":"afery-t"} - second JSON
I aim to create a single Class in Angular 2
export class dictionary{
id:number;
dictValue:string;
}
Is it feasible to convert these different JSON objects into one like this, because this current method is not functioning:
res => <dictionary[]> res.json()
Furthermore, in the HTML template, I am getting JSON object instead of class values in NgFor.
<tr *ngFor="let item of directoryArray">
{{item.test_1}} - I desire {{item.dictValue}}
</tr>
controller
directoryArray:dictionary[];
this._httpService.getAll().subscribe(
data => this.directoryArray = data,
error => alert(error),
() => console.log("Done"));
Thank you for your assistance. Can you please let me know if it is possible or if I need to modify values in the database or create different objects for each JSON?