以下のアイコンコンポーネントを考えてみましょう。 color
変数が補間されるのではなく、色としてそのまま残るのはなぜですか?ngClass補間が機能しない
import {Component, Input, OnInit} from '@angular/core';
@Component({
moduleId: module.id,
selector: 'nui-icon',
template: `
<i class="material-icons"
[ngClass]="{color: true, 'bordered': border}"
[ngStyle]="{'font-size':size + 'px'}">
<ng-content></ng-content>
</i>
`,
styles: [`
i {
display: inline-flex;
}
i.bordered {
border: 1px solid #d8d8d8;
border-radius: 50%;
padding: 15px;
}
`]
})
export class NuiIconComponent implements OnInit {
@Input() color: string;
@Input() size: string = '24';
@Input() border: boolean = false;
constructor() {}
ngOnInit() {
}
}
HostBindingはどこで使用しますか? – yurzui
@yurzuiスクラッチ私は間違ったタイトルを持っていました - ページをリフレッシュすると実際のものが表示されます –
あなたのコードから 'color'は' class 'よりも 'style'の方が多く見えます。そうですか?それ以外の場合は、スタイル配列に記述する必要があります。また、「色」「@入力」は、もともとスタイルとして意図されていたと思う文字列のようです – amal