I have data showing up in my console as this. I want to show them in a dropdown.
["Hello", "Hello"]
0:"Hello"
1:"Hello"
length:2
__proto__:Array(0)
This is what I tried:
<select>
<option *ngFor="let x of greeting" [value]="x">{{x}}<option>
</select>
But nothing is showing up.
And when I use it this way:
<select>
<option>{{greeting}}<option>
</select>
It shows up as one single item in the dropdown as Hello,Hello
UPDATE: Actual Response
{
status: 200,
message: "Rooms are available",
available: "yes",
remaining_room: 10,
price: "[1800,1200]",
extra_person_price: "["500","200"]",
extra_child_price: "["500","100"]",
plan_type: "["EP","PT"]",
plan_name: "["Summer Plan","Winter Plan"]",
}
Response from Network Tab
{status: 200, message: "Rooms are available", available: "yes", remaining_room: 10,…}
available
:
"yes"
extra_child_price
:
"["500","100"]"
extra_person_price
:
"["500","200"]"
message
:
"Rooms are available"
plan_name
:
"["Summer Plan","Costume Plan"]"
plan_type
:
"["CP","others"]"
price
:
"[1800,1200]"
remaining_room
:
10
status
:
200
JSON.parseon that data since it comes as a string from an API. It worked when I used[value]="greeting[x]. But I am also getting an extra empty item in the dropdown at the end. Like a third item.greeting[x]is not correct answer."[\"Hello\", \"Hello\"]"