采用了棱角分明NG式请出了背景图片 [英] using angular ng-style to call out a background image

查看:112
本文介绍了采用了棱角分明NG式请出了背景图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我与使用 NG-风格指令有一个。我想创建一个按钮添加到我的 NG-重复这是CSS精灵。如果我有精灵正常的方式我的元素督察有一个良好的老呻吟。从信息收集我从角文档

我认为这是简单,只要以下内容:

 <按钮NG风格={背景图片:网址:('/ IMG / Myimage.png')'}>测试< /按钮>

不过我是从该行code的接收snytax错误消息。有谁知道正确的方法?


解决方案

 <按钮NG风格={'背景图像':'URL(\\'IMG / MYIMAGE。 PNG \\')'}>测试与LT; /按钮>

是做了正确的道路。失踪逃逸的URL报价'网址:(\\'/ IMG / Myimage.png \\')

I am having an with using the ng-style directive. I want to create add a button to my ng-repeat which is css sprite. If i include the sprite normal way my element inspector has a good old moan. from the information i gather from the Angular documentation

i thought it was as simple as the following:

<button ng-style="{'background-image':'url:('/img/Myimage.png')'}">test</button>

However i am receiving a snytax error message from this line of code. Does anyone know the correct method?

解决方案

<button ng-style="{'background-image':'url(\'img/MyImage.png\')'}">test</button> 

is the correct way to do it. was missing the escape the quotes in url 'url:(\'/img/Myimage.png\')'

这篇关于采用了棱角分明NG式请出了背景图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆