Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 有没有办法在CSS中使用角度路由器参数?_Html_Css_Angular_Angular Material_Angular Router - Fatal编程技术网

Html 有没有办法在CSS中使用角度路由器参数?

Html 有没有办法在CSS中使用角度路由器参数?,html,css,angular,angular-material,angular-router,Html,Css,Angular,Angular Material,Angular Router,我试图使用Angular Router将.ts文件中的参数链接到HTML模板的CSS文件中,例如“background image:{{image}” 我正在使用Angular Material卡组件和*ngFor来显示每个人的个人资料。我试图使用Angular Router根据列表(.ts)文件中设置的参数显示不同的标题图像(写为“背景图像”) 但是,“背景图像”是在CSS文件中设置的,我无法找到在CSS中使用.ts文件中的参数的方法 我想将图像URL与其他参数一起放入.ts文件中,然后将其链

我试图使用Angular Router将.ts文件中的参数链接到HTML模板的CSS文件中,例如“background image:{{image}”

我正在使用Angular Material卡组件和*ngFor来显示每个人的个人资料。我试图使用Angular Router根据列表(.ts)文件中设置的参数显示不同的标题图像(写为“背景图像”)

但是,“背景图像”是在CSS文件中设置的,我无法找到在CSS中使用.ts文件中的参数的方法

我想将图像URL与其他参数一起放入.ts文件中,然后将其链接到CSS文件中,如下所示:

背景图像:url({{header}})
或者为每个人定制一个类,如下所示:

class=“{{customclass}}”
这是卡的模板:


{{busker.name}
这是配置文件图片(标题图像)的CSS类:

。标题图像{
背景图像:url('https://yt3.ggpht.com/a/AGF-l784OUQLYfEn7Hiwd- 
CGG0VXTWWWALWMRPOLW9A=s900-mo-c-C0XFFFFFF-rj-k-no’;
背景尺寸:封面;
}

我希望网格中每个配置文件卡的背景图像URL都不同。

我认为您可以使用类似于
[ngStyle]=“{'background-image':'URL('+bgmagevariable+')')}”
。顺便说一句,我是从SO那里选的,所以你可能想在发布问题之前搜索一下。这对我很有用,谢谢。我确实很努力地在堆栈溢出上寻找答案,但我想我只是把我的搜索写错了。