我在 Angular 中创建了一个简单的指令,它生成一个滚动条来显示一些产品。
我对代码的一部分有疑问。
<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>
在我的页面上执行此操作后,我得到了滚动条,并且“li”元素内的 ng 样式正确显示,而“ul”的 ng 样式则没有。
我尝试了多种解决方案,甚至尝试从“li”元素添加完全相同的 ng 样式,但它只是没有得到处理,也没有添加任何样式。
任何人都可以通过指出我的标记中的错误或可能的原因来帮助我,一种 ng 风格在 Li 元素上工作而另一种在 UL 本身上不起作用?
我遇到的另一个问题是 currentMargin 的值在 IE8/9 等中没有更新。
谢谢