In my project, I have stored data in a JSON file structured as follows:
{
"name": {
"source1": ____,
"source2": ____,
"source3": ____
},
"xcoord": {
"source1": ____,
"source2": ____,
"source3": ____
}
}
To import this JSON data into my component through a service, I followed this guide (refer to "Executing multiple concurrent http requests").
Now, I am looking to create an ngFor
loop that will iterate over the "name" key and display the name values for each source within a <select>
element. Additionally, I want to set the value
of each <option>
to correspond with the "source1", "source2", and "source3" values in the "name" key of the JSON object.
As I am relatively new to TypeScript/Angular 2, I'm unsure about the best approach for achieving this. Would it be more effective to create a pipe for the ngFor
loop to interpret my object as an array, or should I develop a new class to reformat the data and return an array of names?
I lack knowledge on how to proceed with either method, so any guidance would be greatly appreciated!