Topic: Default Value Material Select MDB PRO 5.1.1

itdev pro asked 6 years ago


how do you set the default value of Material Select? I was not able to find the solution in your current documentation.


Damian Gemza staff answered 6 years ago


Dear itdev, Why do you think, that Angular 5 does not support ngModel? Please try one more time use following code: component.html:
<mdb-select [(ngModel)]="selectedCharacter" [options]="dateOptionsSelect" placeholder="Choose time period"></mdb-select>
component.ts:
dateOptionsSelect = [

{ value: '1', label: 'Today', selected: true },

{ value: '2', label: 'Yesterday' },

{ value: '3', label: 'Last 7 days' },

{ value: '4', label: 'Last 30 days' },

{ value: '5', label: 'Last week' },

{ value: '6', label: 'Last month' }

];

selectedCharacter='1';
Please remember to import FormsModule in your's app.module.ts. If this won't work to you, please check console. If console is empty, please let me know again. Best Regards, Damian

itdev pro answered 6 years ago


The issue is not resolved. The link you added is for MDBootstrap version 4. I am using version 5 and it does not support ngModel.

Damian Gemza staff answered 6 years ago


Hello itdev, Please check this link: https://mdbootstrap.com/support/default-value-select-angular/ and follow to my friend - Dawid's advices. Best Regards, Damian

dxl pro commented 6 years ago

I asked same question before. I think this is a pretty important behavior and should be documented (for backwards compatibility in future updates).

Damian Gemza staff commented 6 years ago

Thanks for report. We will add this to docs in nearest future. Best Regards, Damian


Please insert min. 20 characters.

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