角重复&LT;跨度&GT; n次 [英] Angular repeat <span> n times
本文介绍了角重复&LT;跨度&GT; n次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含一个int属性的JSON对象 X
,我想重复以下code x次
I have a JSON object that contains an int property x
, I would like to repeat following code x times
<span class="glyphicon glyphicon-star"/>
纳克重复似乎并不被表示为它的工作与收藏。结果
任何建议(角新手)
ng-repeat does not seem to be indicated as it's working with collection.
Any suggestion (angular newbie)
推荐答案
我会使用自定义与 NG-重复过滤
:
HTML
<div ng-app='myApp' ng-controller="Main">
<li ng-repeat="n in [] | range:20">
<span class="glyphicon glyphicon-star" >{{n}}</span>
</li>
</div>
过滤器
app.filter('range', function() {
return function(val, range) {
range = parseInt(range);
for (var i=0; i<range; i++)
val.push(i);
return val;
};
});
演示<大骨节病> 小提琴 骨节病>
这篇关于角重复&LT;跨度&GT; n次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文