我尝试这个时有一个解析语法错误:
<div ng-repeat="post in posts" id="{{post.idFB}}">
<p>{{post.name}}</p>
<ul>
<li ng-repeat="feed in feed{{post.idFB}}">
<p>{{feed.title}}</p>
</li>
<ul>
</div>
问题是行<li ng-repeat="feed in feed{{post.idFB}}">
,什么是好的语法?
预期结果如feed846097918756247
在线应用:http://www.monde-du-rat.fr/pmr/
编辑:jmb.mage解决方案:
<ul ng-init="myFeed = myFeedFunction(raterie.idFB);">
<li ng-repeat="feed in myFeed | limitTo:1">adoptions are : {{feed.title}}</li>
<li ng-repeat="feed in feed846097918756247 | limitTo:1">search is : {{feed.title}}</li>
<ul>
只有第二个li工作,而不是第一个具有自动变量
答案 0 :(得分:0)
如果feed846097918756247
是JavaScript对象而不是像这样做
<div ng-repeat="post in posts" id="{{post.idFB}}">
<p>{{post.name}}</p>
<ul ng-init="var myFeed = eval('feed' + post.idFB);">
<li ng-repeat="feed in myFeed">
<p>{{feed.title}}</p>
</li>
<ul>
</div>
虽然它使用eval()
,但您可能需要使用以下功能执行ng-init:
<ul ng-init="var myFeed = myFeedFunction(post.idFB);">
然后在你的控制器中有一个功能:
function myFeedFunction(pId) {
return eval('feed' + pId) ;
}
答案 1 :(得分:0)
我只使用Feed对象,如下所示,scope.feed [scope.posts [index] .idFB] =&#39;无论什么&#39;
<div ng-repeat="post in posts" id="{{post.idFB}}">
<p>{{post.name}}</p>
<ul>
<li ng-repeat="feed in feed[post.idFB]">
<p>{{feed.title}}</p>
</li>
<ul>
</div>