I have a textarea and one dropdown. I want whatever string i enters in textarea, that string will appear in the drop-down as an option. Suppose if I enter in textarea as 'zcxvbnuyt', then after pressing 'enter', this string would make the drop-down option.
And the choices I have to send on server must have a string with \n as separator between multiple choices.
Here is my HTML file:
app.component.html
<div class="col-sm-6">
<textarea rows="4"
cols="50"
class="form-control input-sm"
id="Choices"
[(ngModel)]="model.Choices">
</textarea>
</div>
<div class="col-sm-6">
<select class="form-control input-sm"
[(ngModel)]="model.DefaultValue"
[ngModelOptions]="{standalone: true}"
required>
<option *ngFor="let c of defaultOptions" [ngValue]="c.value">{{c.value}}</option>
</select>
</div>
app.component.ts
export class model{
Choices: string;
DefaultValue:string;
}
defaultOptions= [
{ value: 'dummy1' },
{ value: 'dummy2' }
];