11import { Component } from '@angular/core' ;
2- import { MdChipInputEvent } from '@angular/material' ;
2+ import { MdChipInputEvent , MdSnackBar } from '@angular/material' ;
33
44
55export interface Person {
@@ -29,6 +29,15 @@ export class ChipsAccessibilityDemo {
2929 { name : 'Paul' }
3030 ] ;
3131
32+ availableColors = [
33+ { name : 'none' , color : '' } ,
34+ { name : 'Primary' , color : 'primary' } ,
35+ { name : 'Accent' , color : 'accent' } ,
36+ { name : 'Warn' , color : 'warn' }
37+ ] ;
38+
39+ constructor ( public snackBar : MdSnackBar ) { }
40+
3241 displayMessage ( message : string ) : void {
3342 this . message = message ;
3443 }
@@ -39,20 +48,24 @@ export class ChipsAccessibilityDemo {
3948
4049 // Add our person
4150 if ( ( value || '' ) . trim ( ) ) {
42- this . people . push ( { name : value . trim ( ) } ) ;
51+ const name = value . trim ( ) ;
52+ this . people . push ( { name : name } ) ;
53+ this . snackBar . open ( `${ name } added` , '' , { duration : 2000 } ) ;
4354 }
4455
4556 // Reset the input value
4657 if ( input ) {
4758 input . value = '' ;
4859 }
60+
4961 }
5062
5163 remove ( person : Person ) : void {
5264 let index = this . people . indexOf ( person ) ;
5365
5466 if ( index >= 0 ) {
5567 this . people . splice ( index , 1 ) ;
68+ this . snackBar . open ( `${ person . name } deleted` , '' , { duration : 2000 } ) ;
5669 }
5770 }
5871
@@ -61,10 +74,4 @@ export class ChipsAccessibilityDemo {
6174 }
6275
6376
64- availableColors = [
65- { name : 'none' , color : '' } ,
66- { name : 'Primary' , color : 'primary' } ,
67- { name : 'Accent' , color : 'accent' } ,
68- { name : 'Warn' , color : 'warn' }
69- ] ;
7077}
0 commit comments