ng-repeat递归循环使浏览器崩溃

时间:2015-07-14 09:04:01

标签: javascript angularjs loops recursion

好的,我有以下指令:

    app.directive("menuItem", function() {
    return {
        restrict : "E",
        templateUrl: 'tpl/directives/menu-item.html',
        scope: {
            category: '='
        },
        link: function(scope,element, attr){

        }
    };
});

这就是这样称呼的:

顶级

    <!-- list -->
<ul class="nav" ng-controller="NavController">
    <menu-item ng-repeat="category in categories" category="category"></menu-item>
</ul>
<!-- / list -->

菜单-item.html

    <li>
    <a href="" class="auto" ng-if="category.subcategories.length > 0">
          <span class="pull-right text-muted">
            <i class="fa fa-fw fa-angle-right text"></i>
            <i class="fa fa-fw fa-angle-down text-active"></i>
          </span>
        <span>{{category.name}}</span>
    </a>
    <a ui-sref="app.ui.googlemap" href="#/app/ui/googlemap" ng-if="category.subcategories.length <= 0">
        <span>{{category.name}}</span>
    </a>
    <ul class="nav dker" ng-if="category.subcategories.length > 0">
        <menu-item ng-repeat="cat in category.subcategories" category="cat"></menu-item>
    </ul>
</li>

在我可以启动控制台之前,基本没有控制台错误。

有谁能告诉我如何解决这个问题?

0 个答案:

没有答案