Folks,
I am looking through a array in angular. For each element in the array there is a width attribute which dictates what the width of this element should be on screen. However, this does not get renedred for some reason.
我正在寻找一个有角度的数组。对于数组中的每个元素,都有一个width属性,用于指示此元素在屏幕上的宽度。但是,由于某些原因,这不会被重新加入。
The array is as below:
数组如下:
$scope.header = [
{'column':'name', 'width':'300'},
{'column':'city', 'width':'300'},
{'column':'address', 'width':'300'},
{'column':'age', 'width':'300'}
];
The view is as below
视图如下
<div ng-repeat="element in header" >
<span ng-bind="element.column" style="display:inline-block;width:{{element.width}}" >
</span>
</div>
Please advice
3 个解决方案
#2
0
C. S. is right about needing {{element.width}}px
. Here's a fiddle to demonstrate. http://jsfiddle.net/nordyke/T7cW7/
C. S.对于需要{{element.width}} px是正确的。这是一个小提琴演示。 http://jsfiddle.net/nordyke/T7cW7/
#3
0
All you need to do is add px after your {{expression}}, here is the working fiddle
您需要做的就是在{{表达式}}之后添加px,这是工作小提琴
<span ng-bind="element.column" style="display:inline-block;width:{{element.width}}px" >
or even this:
甚至这个:
<span ng-bind="element.column" style="display:inline-block;width:{{element.width+'px'}}" >
#1
#2
0
C. S. is right about needing {{element.width}}px
. Here's a fiddle to demonstrate. http://jsfiddle.net/nordyke/T7cW7/
C. S.对于需要{{element.width}} px是正确的。这是一个小提琴演示。 http://jsfiddle.net/nordyke/T7cW7/
#3
0
All you need to do is add px after your {{expression}}, here is the working fiddle
您需要做的就是在{{表达式}}之后添加px,这是工作小提琴
<span ng-bind="element.column" style="display:inline-block;width:{{element.width}}px" >
or even this:
甚至这个:
<span ng-bind="element.column" style="display:inline-block;width:{{element.width+'px'}}" >