docs(chips): use consistent data structure in autocomplete example (#11175)

This commit is contained in:
Kyoz
2018-05-10 01:35:54 +07:00
committed by Jeremy Elbourn
parent c58f6bf8a3
commit 714f0652e5
2 changed files with 9 additions and 8 deletions
@@ -4,8 +4,8 @@
*ngFor="let fruit of fruits"
[selectable]="selectable"
[removable]="removable"
(remove)="remove(fruit)">
{{fruit.name}}
(removed)="remove(fruit)">
{{fruit}}
<mat-icon matChipRemove *ngIf="removable">cancel</mat-icon>
</mat-chip>
<input
@@ -26,14 +26,15 @@ export class ChipsAutocompleteExample {
filteredFruits: Observable<any[]>;
fruits = [
{ name: 'Lemon' },
'Lemon',
];
allFruits = [
'Orange',
'Strawberry',
'Lime',
'Apple',
'Lemon',
'Lime',
'Orange',
'Strawberry'
];
@ViewChild('fruitInput') fruitInput: ElementRef;
@@ -50,7 +51,7 @@ export class ChipsAutocompleteExample {
// Add our fruit
if ((value || '').trim()) {
this.fruits.push({ name: value.trim() });
this.fruits.push(value.trim());
}
// Reset the input value
@@ -73,7 +74,7 @@ export class ChipsAutocompleteExample {
}
selected(event: MatAutocompleteSelectedEvent): void {
this.fruits.push({ name: event.option.viewValue });
this.fruits.push(event.option.viewValue);
this.fruitInput.nativeElement.value = '';
}
}