In the React module it supports String syntax. The idea is that an icon can be registered once with a name, and can then be used by providing that name.
This is a really nice feature.
The Angular module could support this using the following solution:
Create a IconService with a method addIcon:
@Injectable({
providedIn: 'root',
})
export class IconService {
private icons = {};
addIcon(name: string, icon: string) {
this.icons[name] = icon;
}
getIcon(name: string) {
const icon = this.icons[name];
if(!icon){
throw new Error(`[Iconify]: No icon registered for name '${name}'. Call 'IconService.addIcon' to register icons.`);
}
return icon;
}
}
In the React module it supports String syntax. The idea is that an icon can be registered once with a name, and can then be used by providing that name. This is a really nice feature.
The Angular module could support this using the following solution:
Create a
IconService
with a methodaddIcon
:Adjust the the directive:
Usage in template:
Registerering icons: