使用Angular更改CSS值
在我的项目中,我使用“ ngb-progressbar”元素来绘制进度栏。 要手动为此栏设置CSS,我正在使用此代码:
::ng-deep div.bg-success.progress-bar{
background: linear-gradient(90deg, rgba(54,166,5,1) 0%, rgb(219, 238, 52) 100%) !important;
background-size: 100% !important;
background-repeat: no-repeat !important;
}
在我的ts代码中,我需要尼斯设置背景大小属性的价值,并且为此,我正在寻找一种使用“ :: ng-deep”。 删除“ :: ng-deep”更改没有效果。
通过使用:: ng-deep通过TS代码访问我的元素样式有什么想法吗?
In my project I'm using a "ngb-progressbar" element to draw a progress-bar.
To manually set the css for this bar I'm using this piece of code:
::ng-deep div.bg-success.progress-bar{
background: linear-gradient(90deg, rgba(54,166,5,1) 0%, rgb(219, 238, 52) 100%) !important;
background-size: 100% !important;
background-repeat: no-repeat !important;
}
In my TS code I need to set nynamically the value of background-size attribute and to do this I'm looking for a method to access to the element with "::ng-deep".
Removing "::ng-deep" changes have no effect.
Any idea to access my element style via TS code by using ::ng-deep ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用以下HTML,
以便您可以使用以下SCSS
这是最清洁的解决方案。另一个解决方案涉及在Vanillajs或可能是
Renderer2
的帮助下手动更改HTML,这是Meh。Use the following HTML
So that you can use the following SCSS
This is the cleanest solution at your disposal. The other solution involves manually changing the HTML with the help of vanillaJS or maybe the
Renderer2
, which are kind of meh.