2015-10-19 45 views
1

我得到一個Error: parent is null [email protected]:3448:7錯誤從角度的forEach迭代器。我相信這是來自一個嵌套的重複。錯誤:父母爲空 - angular.js

tbody(ng-repeat='comment in comments' ng-include="'../../components/comment.html'") 
       include ../../components/comment.jade 
       tr.athing(ng-if="comment.kids" ng-include="'../../components/comment.html'", ng-repeat='comment in comment.kids') 
        include ../../components/comment.jade 

我正在嘗試遍歷一個嵌套的註釋結構。

+1

提供角度看到的呈現的html結構。請注意'ng-include'創建一個子範圍。不知道這是否有意義把它放在'' – charlietfl

+0

ng重複不應該在''這不是重複。我正在製作一個hackernews克隆,以便我的html符合他們的要求。 –

+0

在編輯和發佈新問題之間進行辯論。 –

回答

0

你應該使用ngInclude玉包括,但不是兩個。此外,您無法在使用ngInclude的元素上使用子DOM。

0

我的第一反應是從您的代碼中刪除ng-include,因爲您似乎在您的模板中將它內聯?我可能是錯的,但這將是我的第一反應。 ng-include使用transclusion,並可能產生一些意想不到的行爲。

tbody(ng-repeat='comment in comments') 
    include ../../components/comment.jade 
     tr.athing(ng-if="comment.kids" ng-repeat='comment in comment.kids') 
      include ../../components/comment.jade