Skip to content

Commit 0cccb44

Browse files
committed
Add multiple selection and single selection to chip list
1 parent 4bc7fbc commit 0cccb44

File tree

4 files changed

+292
-124
lines changed

4 files changed

+292
-124
lines changed

src/demo-app/chips/chips-demo.html

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ <h4>Stacked Chips</h4>
128128
</md-chip-list>
129129

130130
<h4>NgModel with chip list</h4>
131-
<md-chip-list [(ngModel)]="selectedColors">
131+
<md-chip-list [multiple]="true" [(ngModel)]="selectedColors">
132132
<md-chip *ngFor="let aColor of availableColors" color="{{aColor.color}}"
133133
[value]="aColor.name" (remove)="removeColor(aColor)">
134134
{{aColor.name}}
@@ -137,6 +137,17 @@ <h4>NgModel with chip list</h4>
137137
</md-chip-list>
138138

139139
The selected colors are <span *ngFor="let color of selectedColors"> {{color}}</span>.
140+
141+
<h4>NgModel with single selection chip list</h4>
142+
<md-chip-list [(ngModel)]="selectedColor">
143+
<md-chip *ngFor="let aColor of availableColors" color="{{aColor.color}}"
144+
[value]="aColor.name" (remove)="removeColor(aColor)">
145+
{{aColor.name}}
146+
<md-icon mdChipRemove>cancel</md-icon>
147+
</md-chip>
148+
</md-chip-list>
149+
150+
The selected color is {{selectedColor}}.
140151
</md-card-content>
141152
</md-card>
142153
</div>

src/demo-app/chips/chips-demo.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,5 @@ export class ChipsDemo {
9393
this.visible = false;
9494
}
9595
selectedColors: any[] = ['Primary', 'Warn'];
96+
selectedColor = 'Accent';
9697
}

0 commit comments

Comments
 (0)