Topic: problem with select option in Angular
Damian Gemza
staff
answered 7 years ago
Dear Yo,
You're able to get value of selected item by using ngModel attribute.
Just look at my code.
html:
ts:
Remember to import FormsModule in your app.module to use ngModel.
Best Regards,
Damian
<div class="row">
<div class="col-md-6">
<mdb-select [options]="optionsSelect"placeholder="Choose your option" [(ngModel)]="value"></mdb-select>
<label>Example label</label>
<p>Select value: {{value}}</p>
</div>
</div>
value: string;
optionsSelect:Array<any>;
ngOnInit() {
this.optionsSelect= [
{ value: '1', label: 'Option 1' },
{ value: '2', label: 'Option 2' },
{ value: '3', label: 'Option 3' },
];
}
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Status
Resolved
Specification of the issue
- ForumUser: Pro
- Premium support: No
- Technology: MDB Angular
- MDB Version: -
- Device: -
- Browser: -
- OS: -
- Provided sample code: No
- Provided link: No
Tags