【发布时间】:2019-10-28 23:24:59
【问题描述】:
如果我单击一个按钮,我想为我的组件添加一个新样式。 我想切换它。
默认是 my.componenet.scss
新版本是 my2.componenet.scss
它是我的组件加载,当我点击一个函数时我会改变 styleurls
@Component({
selector: 'mycomponent',
templateUrl: './mycomponent.component.html',
styleUrls: ['./mycomponent.component.scss'],
})
这是我的功能
public LoadDefaultStyle(){
// loading it styleUrls: ['./my.componenet.scss'], after rendering page
}
public LoadNewStyle(){
// loading it styleUrls: ['./my2.componenet.scss'], after rendering page
}
你能给我一些指导吗?
【问题讨论】:
-
也许你可以使用这个答案?它似乎与您的问题非常相似。 stackoverflow.com/questions/37730801/…
-
嗨,我认为这不是满足您要求的正确方法。请参考 Angular 主题文档 ==> material.angular.io/guide/theming-your-components
-
它对我有用 mangeshbhuskute
标签: angular click components styles