我正在寻找一种方法来调整组件的大小
使用fontAwesome库
import { library } from '@fortawesome/fontawesome-svg-core';
import {
faBell
} from '@fortawesome/free-solid-svg-icons';
library.add(
faBell
);
@Component({
changeDetection: ChangeDetectionStrategy.OnPush,
selector: 'iwdf-icon-bell',
template: `<fa-icon [ngClass]="cls" [icon]="['fas', 'bell']"></fa-icon>`,
styles: [`:host {
display: inline-block;
}`]
})
export class IconBellComponent{
@Input() cls: string;
}
但我有个错误:
Can't bind to 'ngClass' since it isn't a known property of 'fa-icon'.
我知道我会作弊,比如:
@组件({
changeDetection: ChangeDetectionStrategy.OnPush,
selector: 'iwdf-icon-bell',
template: `<fa-icon class="{{cls}}" [icon]="['fas', 'bell']"></fa-icon>`,
styles: [`:host {
display: inline-block;
}`]
})
export class IconBellComponent{
@Input() cls: string;
}
但我想知道还有没有别的办法。
知道吗?
更新
我是用以下方法计算出来的:
@Component({
changeDetection: ChangeDetectionStrategy.OnPush,
selector: 'icon-angledown',
template: `<fa-icon [className]="cls" [icon]="['fas', 'angle-down']"></fa-icon>`,
styles: [`:host {
display: inline-block;
}`]
})
export class IconAngleDownComponent{
@Input() cls: string = '';
}