I have to set the option value of my select using a JSON file. The Object is the following:
export class Car { ID: String; Name: [{ confName: String } }] } I am trying to set it with the following code:
this.baseService.getCars(message) .subscribe(cars => { this.cars = cars; myCars = this.cars; //Car is a global variable }); var $el = $("#carSelect"); $el.empty(); // remove old options $.each(myCars, function (key, value) { $el.append($("<option></option>") .attr("value", value).text(key)); }); I know that for accessing to the confName of one of them I need to use console.log(myCars[0].Name.confName); so probably the error is here:
$.each(myCars because I need to access to Name to get then the value,key of confName I want to do it for each each