Skip to content

Commit 714f065

Browse files
kyozjelbourn
authored andcommitted
docs(chips): use consistent data structure in autocomplete example (#11175)
1 parent c58f6bf commit 714f065

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/material-examples/chips-autocomplete/chips-autocomplete-example.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
*ngFor="let fruit of fruits"
55
[selectable]="selectable"
66
[removable]="removable"
7-
(remove)="remove(fruit)">
8-
{{fruit.name}}
7+
(removed)="remove(fruit)">
8+
{{fruit}}
99
<mat-icon matChipRemove *ngIf="removable">cancel</mat-icon>
1010
</mat-chip>
1111
<input

src/material-examples/chips-autocomplete/chips-autocomplete-example.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@ export class ChipsAutocompleteExample {
2626
filteredFruits: Observable<any[]>;
2727

2828
fruits = [
29-
{ name: 'Lemon' },
29+
'Lemon',
3030
];
3131

3232
allFruits = [
33-
'Orange',
34-
'Strawberry',
35-
'Lime',
3633
'Apple',
34+
'Lemon',
35+
'Lime',
36+
'Orange',
37+
'Strawberry'
3738
];
3839

3940
@ViewChild('fruitInput') fruitInput: ElementRef;
@@ -50,7 +51,7 @@ export class ChipsAutocompleteExample {
5051

5152
// Add our fruit
5253
if ((value || '').trim()) {
53-
this.fruits.push({ name: value.trim() });
54+
this.fruits.push(value.trim());
5455
}
5556

5657
// Reset the input value
@@ -73,7 +74,7 @@ export class ChipsAutocompleteExample {
7374
}
7475

7576
selected(event: MatAutocompleteSelectedEvent): void {
76-
this.fruits.push({ name: event.option.viewValue });
77+
this.fruits.push(event.option.viewValue);
7778
this.fruitInput.nativeElement.value = '';
7879
}
7980
}

0 commit comments

Comments
 (0)