本文介绍了采用了棱角分明NG-风格,在IE浏览器不更新的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个角一个简单的指令,它会生成一个滚动条来显示一些产品。

I've created a simple directive in Angular which generates a scroller to display some products.

我在与code的一部分的问题。

I'm having an issue with one part of the code.

            <ul ng-style="{'margin-left':{{currentMargin}}+'px'}">
                <li ng-repeat="tyre in tyres" ng-style="{'width':{{liWidth}}+'px'}">
                    <div class="imageContainer"><img src="../Images/eutl/{{tyre.image}}"/></div>
                    <div class="details">
                        <h3>{{tyre.name}}</h3>
                        <a href="{{tyre.link}}">About this tire</a>
                    </div>
                </li>
            </ul>

and this is what it looks like in the browser once executed
<ul ng-style="{'margin-left':0+'px'}">
<!-- ngRepeat: tyre in tyres -->
<li ng-repeat="tyre in tyres" ng-style="{'width':265+'px'}" class="ng-scope" style="width: 265px;">
    <div class="imageContainer"><img src="../Images/eutl/tire.jpg"></div>
    <div class="details">
        <h3 class="ng-binding">Fuel Efficient</h3>
        <a href="#">About this tire</a>
    </div>
</li>
<!-- end ngRepeat: tyre in tyres --></ul>

我的网页上执行此之后,我得到的滚动条和礼元素中的NG-Style获取正确显示,而NG式的UL没有。

after executing this on my page I get the scroller and the ng-style inside the "li" elements gets displayed correctly, while the ng-style for the "ul" doesn't.

我尝试过多种解决方案,甚至还试图从礼元素添加完全相同的NG-风格,它只是没有得到处理,不添加的风格。

I've tried multiple solutions, even trying to add the same exact ng-style from the "li" element and it just doesn't get processed and no style is added.

谁能帮我通过指出我的标记错误或可能的原因一NG式工作的李元素和其他没有工作的UL本身呢?

Can anyone help me by pointing out a mistake in my markup or a possible cause for one ng-style working on the Li elements and the other not working on the UL itself?

时遇到的另一问题是,currentMargin的值未在IE8 / 9更新等。

The other problem I'm having is that the value of the currentMargin is not updating in IE8/9 and so on.

感谢

推荐答案

NG-风格接受一个的中的一个对象。这意味着,如果你想使用前pression里面的变量,你可以直接使用它(没有双花括号):

ng-style accepts an Angular expression that evaluates to an object. This means that if you want to use a variable inside that expression, you can use it directly (without the double-curlies):

ng-style="{width: liWidth + 'px'}"

当你想要一个动态的,插值插入到接受一个字符串,如℃的论点双花括号使用; IMG ALT ={{product.name}}标志&GT; 。然后你把一个前pression的 的内部那些括号内。

Double-curlies are used when you want to insert a dynamic, interpolated value to an argument that accepts a string, like <img alt="{{product.name}} logo">. You then put an expression inside those brackets.

这篇关于采用了棱角分明NG-风格,在IE浏览器不更新的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 00:28