【发布时间】:2017-03-29 13:45:50
【问题描述】:
我有一个组件,其中包含四种不同的可能样式文件,可以根据某些变量应用这些样式文件。如何在渲染之前应用该组件的样式?
@Component({
selector: 'settings-editor',
templateUrl: './settings-editor.component.html',
styleUrls: [ './a.less', './b.less' , './c.less' ]
})
export class SettingsEditorComponent implements OnInit {
@Input()
public styleType: string;
ngOnInit() {
if (this.styleType === 'A') {
// Apply styles from a.less only
}
}
}
【问题讨论】:
标签: angular angular2-components