question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

md-select default value

See original GitHub issue

Bug, feature request, or proposal:

When using formBuilder default value passed to formBuilder does not show as selected in md-select.

What is the expected behavior?

If I select value in formBuilder its name and value should appear as selected option of md-select.

What is the current behavior?

Placeholder is displayed instead.

What are the steps to reproduce?

typescript: this.editForm = this.formBuilder.group({ projectId: [this.task.project._id] }); or: this.editForm = this.formBuilder.group({ projectId: new FormControl({value: this.task.project._id}, Validators.required) });

html: <form layout="column" [formGroup]="editForm" (ngSubmit)="saveTask(task)"><md-select formControlName="projectId" name="project" placeholder="{{'FORM.PROJECT' | translate }}"><md-option *ngFor="let project of projects | async" [value]="project._id">{{project.name}}</md-option></md-select><select formControlName="projectId" name="project"><option *ngFor="let project of projects | async" [value]="project._id">{{project.name}}</option></select></form>

standard html works, md does’t

What is the use-case or motivation for changing an existing behavior?

Edit forms. Lets have a class with 20 attributes each of them can be changed using one form. You don’t want to refill all these attributes if you want to change just one.

Which versions of Angular, Material, OS, browsers are affected?

Angular 2.2.1 Material 2.0.0-beta.1 WIN 10 Vivaldi Firefox tested (but probably all affected)

Is there anything else we should know?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
jeewanaryal2012commented, Sep 28, 2017

Please open this issue, I am having the same issue now. The default value does not show up, it shows the placeholder instead.

0reactions
angular-automatic-lock-bot[bot]commented, Sep 10, 2019

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to set default value in md-select - angularjs
Just set ngModel(RAMVal) value to whichever option you want to be selected by default. ex : $scope.RAMVal = '300mb'; Reference Link : ...
Read more >
Directives > mdSelect - AngularJS Material
By default, the select will display with an underline to match other form elements. This can be disabled by applying the md-no-underline CSS...
Read more >
Set Default option for md-select - CodePen
When option is opened, selected option is not highlighted. ng-model initial value is set, and initial value is highlighted in the options.
Read more >
md-select default value · Issue #1863 · angular/material - GitHub
It shows the default option but it doesn't set the value, so when I retrieve it with $scope.model, the value is undefined, like...
Read more >
How to set default selected option in md-select component ...
I want to set the default value from my md-select. This default value is an object. When i work with a "simple" value...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found