I have a json file contains a icons object like this:
"icons" : {
"logo" : "fa fa-caret-down",
"search" : "fas fa-search",
"bell" : "far fa-bell"
}
In my component.ts, I am able to get this icons object using a service successfully like this:
navIcons: object;
getNavIcons(): void {
this.navbarService.getNavIcons()
.subscribe(navIcons => {
this.navIcons = navIcons;
console.log(this.navIcons)
// icons : {
// logo : "fa fa-caret-down",
// search : "fas fa-search",
// bell : "far fa-bell"
// }
});
}
How can I bind thoes class in the component.html template? I tried like this:
<i id="logo" [ngClass]="['navIcons.logo']" class="nav-icon"></i>
but it failed. I also have another calss: nav-icon need to added into this logo? Thank you in advanced!