Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,15 @@ export class ChipsAutocompleteExample {
}

add(event: MatChipInputEvent): void {
const input = event.input;
const value = event.value;
const value = (event.value || '').trim();

// Add our fruit
if ((value || '').trim()) {
this.fruits.push(value.trim());
if (value) {
this.fruits.push(value);
}

// Reset the input value
if (input) {
input.value = '';
}
// Clear the input value
event.chipInput!.clear();

this.fruitCtrl.setValue(null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,15 @@ export class ChipsInputExample {
];

add(event: MatChipInputEvent): void {
const input = event.input;
const value = event.value;
const value = (event.value || '').trim();

// Add our fruit
if ((value || '').trim()) {
this.fruits.push({name: value.trim()});
if (value) {
this.fruits.push({name: value});
}

// Reset the input value
if (input) {
input.value = '';
}
// Clear the input value
event.chipInput!.clear();
}

remove(fruit: Fruit): void {
Expand Down
13 changes: 5 additions & 8 deletions src/dev-app/chips/chips-demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {Component} from '@angular/core';
import {MatChipInputEvent} from '@angular/material/chips';
import {ThemePalette} from '@angular/material/core';


export interface Person {
name: string;
}
Expand Down Expand Up @@ -61,17 +60,15 @@ export class ChipsDemo {
}

add(event: MatChipInputEvent): void {
const {input, value} = event;
const value = (event.value || '').trim();

// Add our person
if ((value || '').trim()) {
this.people.push({ name: value.trim() });
if (value) {
this.people.push({ name: value });
}

// Reset the input value
if (input) {
input.value = '';
}
// Clear the input value
event.chipInput!.clear();
}

remove(person: Person): void {
Expand Down
12 changes: 5 additions & 7 deletions src/dev-app/mdc-chips/mdc-chips-demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,15 @@ export class MdcChipsDemo {
}

add(event: MatChipInputEvent): void {
const {input, value} = event;
const value = (event.value || '').trim();

// Add our person
if ((value || '').trim()) {
this.people.push({ name: value.trim() });
if (value) {
this.people.push({ name: value });
}

// Reset the input value
if (input) {
input.value = '';
}
// Clear the input value
event.chipInput!.clear();
}

remove(person: Person): void {
Expand Down
Loading