I need simple code help. If I choose any particular letter then corresponding countries should be displayed, in my current position I am not able to do it dynamically. For example if i choose letter A then countries pertaining to those should be displayed outside the select.
<select [(ngModel)]="selectedOption">
<option *ngFor="let o of options">
{{o.letter}}
</option>
</select>
<p *ngFor="let o of options">Countries are: {{ o.countries }}</p>
export class AppComponent {
selectedOption: string;
options = [
{ letter: "A", countries: ["Afghanistan", "Albania", "Argentina"] },
{ letter: "B", countries: ["Bangladesh", "Bahamas", "Bahrain"] }
]
}
If A chosen then Afghanistan Albania .... If B chosen then .... If C chosen then .... I should be able to expand array in future.