Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/39.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
Css 为什么背景图像的ng样式不';不行?_Css_Angularjs_Ng Style - Fatal编程技术网

Css 为什么背景图像的ng样式不';不行?

Css 为什么背景图像的ng样式不';不行?,css,angularjs,ng-style,Css,Angularjs,Ng Style,我的ng样式如下,不适用于背景: <div ng-repeat="s in slider.slides" class="slide" ng-style="{border: 'solid 4px red', 'background-image': 'url(rsc/selectiontodose/{{s.photo}}.jpg)'}" style="width: {{size}}px; height: {{size}}px; margin:0; left:{{

我的ng样式如下,不适用于背景:

<div
    ng-repeat="s in slider.slides"
    class="slide"
    ng-style="{border: 'solid 4px red', 'background-image': 'url(rsc/selectiontodose/{{s.photo}}.jpg)'}"
    style="width: {{size}}px; height: {{size}}px; margin:0; left:{{-$parent.slide*size}}px;">
</div>

我添加了边框,以确保考虑到hg样式指令本身(边框是红色的)

在DOM中,我看不到背景,而边界实际上在那里


有什么想法吗?

有类似的情况,我发现:

<div class="splash-banner" ng-style="{'background-image': 'url(\'{{banner.backgroundImage}}\')', 'background-color': banner.backgroundColor}">

与以下内容相比,将呈现不一致:

<div class="splash-banner" ng-style="{'background-image': 'url(\'' + banner.backgroundImage + '\')', 'background-color': banner.backgroundColor}">


不幸的是,我不太了解angular,但ng风格的表达式似乎会在{{banner.backgroundImage}有值之前对其求值。我想知道这是否是因为正在从REST请求检索标题项。然后它将默认为当前页面的url(或至少是当前主机名)。

试试
ng style=“{'border':'solid 4px red','background image':'url('+s.photo+')”}
不,插值是可以的(我刚刚做了一个艰难的测试)。@DanielBeckYou插值是对的,抱歉;跳到结论(我经常被这类事情绊倒,所以…)你的代码中没有显示的部分一定有问题;你应该做的是:可能是错误的图像路径?