Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(protected _elementRef: ElementRef,
_changeDetectorRef: ChangeDetectorRef,
@Optional() _dir: Directionality) {
super(_elementRef, _changeDetectorRef, _dir);
this._chipSetAdapter.selectChipAtIndex = (index: number, selected: boolean) => {
this._setSelected(index, selected);
};
// Reinitialize the foundation with our overridden adapter
this._chipSetFoundation = new MDCChipSetFoundation(this._chipSetAdapter);
this._updateMdcSelectionClasses();
}
constructor(protected _elementRef: ElementRef,
protected _changeDetectorRef: ChangeDetectorRef,
@Optional() protected _dir: Directionality) {
super(_elementRef);
this._chipSetFoundation = new MDCChipSetFoundation(this._chipSetAdapter);
}
getDefaultFoundation() {
const adapter: MDCChipSetAdapter = {
hasClass: (className: string) => this._getHostElement().classList.contains(className),
removeChip: (chipId: string) => {
const index = this._findChipIndex(chipId);
this.chips.toArray().splice(index, 1);
},
setSelected: (chipId: string, selected: boolean) => {
const chip = this.getChipById(chipId);
if (chip) {
chip.selected = selected;
}
}
};
return new MDCChipSetFoundation(adapter);
}