Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
ngAfterContentInit() {
this.initRipple();
this.toggleFoundation = new MDCIconButtonToggleFoundation(this.toggleAdapter);
this.toggleFoundation.init();
// the foundation doesn't initialize the iconOn/iconOff and labelOn/labelOff until
// toggle is called for the first time,
// also, this will ensure 'aria-pressed' and 'aria-label' attributes are initialized:
this.toggleFoundation.toggle(this._on);
this._initialized = true;
}
getDefaultFoundation() {
return new MDCIconButtonToggleFoundation({
addClass: (className: string) => this.root.addClass(className),
removeClass: (className: string) => this.root.removeClass(className),
hasClass: (className: string) => this.root.hasClass(className),
setAttr: (attrName: string, attrValue: string | number | null) =>
this.root.setProp(attrName as any, attrValue),
notifyChange: (evtData: { isOn: boolean }) =>
this.emit('onChange', evtData)
});
}
getDefaultFoundation() {
const adapter: MDCIconButtonToggleAdapter = {
addClass: (className: string) => this._getHostElement().classList.add(className),
removeClass: (className: string) => this._getHostElement().classList.remove(className),
hasClass: (className: string) => this._getHostElement().classList.contains(className),
setAttr: (name: string, value: string) => this._getHostElement().setAttribute(name, value),
notifyChange: (evtData: {isOn: boolean}) => {
this.change.emit(new MdcIconButtonChange(this, evtData.isOn));
this._onChange(this._foundation.isOn());
}
};
return new MDCIconButtonToggleFoundation(adapter);
}