Javascript 尝试以角度编译递归指令时,页面暂停
这是我的注释模板,请注意,再次调用app comment,使其嵌套并递归:Javascript 尝试以角度编译递归指令时,页面暂停,javascript,angularjs,recursion,angularjs-directive,Javascript,Angularjs,Recursion,Angularjs Directive,这是我的注释模板,请注意,再次调用app comment,使其嵌套并递归: <div> <div class="app-comment-main"> {{ comment.body }} </div> <ul class="app-comment-replies" ng-hide="comment.replies.length <= 0"> <li class="app-comme
<div>
<div class="app-comment-main">
{{ comment.body }}
</div>
<ul class="app-comment-replies" ng-hide="comment.replies.length <= 0">
<li class="app-comment-container" ng-repeat="comment in comment.replies">
<div class="app-comment" info="comment"></div>
</li>
</ul>
</div>
当试图编译此文件时,页面总是挂起,我假设它卡在无限循环中。我做错了什么,或者怎么做才能有所不同?您的指令没有创建新的作用域,因此它总是在相同的回复上迭代
return {
restrict: "C",
replace: true,
scope: {
comment: "=info"
}
return {
restrict: "C",
replace: true,
scope: {
comment: "=info"
}