Skip to content

md-select with ngModel requires name attribute (hasValue error) #5402

Closed
@kmturley

Description

@kmturley

Bug, feature request, or proposal:

This is a bug with the documentation not matching expected behaviour

What is the expected behavior?

No error when copying guide code

What is the current behavior?

You get an error:
MdSelect.html:1 ERROR TypeError: Cannot read property 'hasValue' of undefined
at Object.View_MdSelect_0.co [as updateDirectives]

What are the steps to reproduce?

Following the guide, and copying example code should render without errors:
https://material.angular.io/components/select/overview

<md-select placeholder="State" [(ngModel)]="myState">
   <md-option *ngFor="let state of states" [value]="state.code">{{ state.name }}</md-option>
</md-select>

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

The error is not useful, also modifying the example code, adding a name attribute to the md-select element fixes the issue:

<md-select placeholder="State" [(ngModel)]="myState" name="states">
   <md-option *ngFor="let state of states" [value]="state.code">{{ state.name }}</md-option>
</md-select>

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

Angular 4.0.2
Angular Material 2.0.0-beta.7
MacOS 10.12.5
TypeScript 2.0.0
Chrome 59.0.3071.109

Is there anything else we should know?

The other example is correct here:
https://material.angular.io/components/select/examples

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions