Angular.js

时间:2015-09-29 14:25:00

标签: javascript angularjs node.js

大家好!

我尝试进行递归以扩展Angular.js中的$ routeProvider这是我试图实现的代码:

var pages = {
'home': {
    'url': '/',
    'partialName': 'index',
    'link': partialDir + this.partialName + pageFormat,
    'controllerName': this.partialName + 'Controller',
    'pageTitle': 'Welcome home'
},
'page': {
    'url': '/page',
    'partialName': 'page',
    'link': partialDir + this.partialName + pageFormat,
    'controllerName': this.partialName + 'Controller',
    'pageTitle': 'Page'
},
'page2': {
    'url': '/page2',
    'partialName': 'page2',
    'link': partialDir + this.partialName + pageFormat,
    'controllerName': this.partialName + 'Controller',
    'pageTitle': 'Page2'
}

angular.forEach(pages, function(value, key) {
    console.log(value);

    $routeProvider.when(value.url,{
        templateUrl: value.link
    })
});

$locationProvider.html5Mode({
    enabled: true,
    requireBase: false
});

我得到了

  

超出最大调用堆栈大小

我该如何解决这个问题?

未捕获异常(匿名函数)@ angular.js:12450ident。$ get @ angular.js:9237invokeLinkFn @ angular.js:8782nodeLinkFn @ angular.js:8280compositeLinkFn @ angular.js:7671publicLinkFn @ angular.js:7546 $ route .link @ angular-route.js:985invokeLinkFn @ angular.js:8780nodeLinkFn @ angular.js:8280compositeLinkFn @ angular.js:7671publicLinkFn @ angular.js:7546name.$ get.boundTranscludeFn @ angular.js:7690controllersBoundTransclude @ angular.js: 8307update @ angular-route.js:935 $ animate.link @ angular-route.js:900invokeLinkFn @ angular.js:8780nodeLinkFn @angular.js:8280compositeLinkFn @ angular.js:7671publicLinkFn @ angular.js:7546 $ route.link @ angular-route.js:985invokeLinkFn @ angular.js:8780nodeLinkFn @ angular.js:8280compositeLinkFn @ angular.js:7671publicLinkFn @ angular.js:7546name.$ get.boundTranscludeFn @ angular.js:7690controllersBoundTransclude @ angular.js:8307update @ angular -route.js:935 $ animate.link @ angular-route.js:900invokeLinkFn @ angular.js:8780nodeLinkFn @ angular.j s:8280compositeLinkFn @ angular.js:7671publicLinkFn @ angular.js:7546 $ route.link @ angular-route.js:985invokeLinkFn @ angular.js:8780nodeLinkFn @ angular.js:8280compositeLinkFn @ angular.js:7671publicLinkFn @ angular.js: 7546名。$ get.boundTranscludeFn @ angular.js:7690controllersBoundTransclude @ angular.js:8307update @ angular-route.js:935 $ animate.link @ angular-route.js:900invokeLinkFn @ angular.js:8780nodeLinkFn @ angular.js:8280compositeLinkFn @ angular.js:7671publicLinkFn @ angular.js:7546 $ route.link @ angular-route.js:985invokeLinkFn @ angular.js:8780nodeLinkFn @angular.js:8280compositeLinkFn @ angular.js:7671publicLinkFn @ angular.js:7546name.$ get.boundTranscludeFn @ angular.js:7690controllersBoundTransclude @ angular.js:8307update @ angular-route.js:935 $ animate.link @ angular-route.js:900invokeLinkFn @ angular.js:8780nodeLinkFn @ angular.js:8280compositeLinkFn @angular。 js:7671publicLinkFn @ angular.js:7546 $ route.link @ angular-route.js:985invokeLinkFn @ angular.js:8780nodeLin kFn @ angular.js:8280compositeLinkFn @ angular.js:7671publicLinkFn @ angular.js:7546name。$ get.boundTranscludeFn @ angular.js:7690controllersBoundTransclude @ angular.js:8307update @ angular-route.js:935 $ animate.link @ angular -route.js:900invokeLinkFn @ angular.js:8780nodeLinkFn @ angular.js:8280compositeLinkFn @ angular.js:7671publicLinkFn @ angular.js:7546 $ route.link @ angular-route.js:985invokeLinkFn @ angular.js:8780nodeLinkFn @ angular .js:8280compositeLinkFn @ angular.js:7671publicLinkFn @ angular.js:7546name。$ get.boundTranscludeFn @ angular.js:7690controllersBoundTransclude @ angular.js:8307update @ angular-route.js:935 $ animate.link @ angular-route。 js:900invokeLinkFn @ angular.js:8780nodeLinkFn @ angular.js:8280compositeLinkFn @ angular.js:7671publicLinkFn @ angular.js:7546 $ route.link @ angular-route.js:985invokeLinkFn @ angular.js:8780nodeLinkFn @ angular.js: 8280compositeLinkFn @ angular.js:7671publicLinkFn @ angular.js:7546name。$ get.boundTranscludeFn @ angular.js:7690controllers BoundTransclude @ angular.js:8307update @ angular-route.js:935 $ animate.link @ angular-route.js:900invokeLinkFn @ angular.js:8780nodeLinkFn @ angular.js:8280compositeLinkFn @ angular.js:7671publicLinkFn @ angular.js: 7546 $ route.link @ angular-route.js:985invokeLinkFn @ angular.js:8780nodeLinkFn @ angular.js:8280compositeLinkFn @ angular.js:7671publicLinkFn @ angular.js:7546name./ get.boundTranscludeFn @ angular.js:7690controllersBoundTransclude @ angular .js:8307update @ angular-route.js:935 $ animate.link @ angular-route.js:900invokeLinkFn @ angular.js:8780nodeLinkFn @ angular.js:8280compositeLinkFn @ angular.js:7671publicLinkFn @ angular.js:7546 $ route .link @ angular-route.js:985invokeLinkFn @ angular.js:8780nodeLinkFn @ angular.js:8280compositeLinkFn @ angular.js:7671publicLinkFn @ angular.js:7546name.$ get.boundTranscludeFn @ angular.js:7690controllersBoundTransclude @ angular.js: 8307update @ angular-route.js:935 $ animate.link @ angular-route.js:900invokeLinkFn @ angular.js:8780nodeLinkFn @ angular.js:8280compositeLinkFn @ angular.js:7671publicLinkFn @ angular.js:7546 $ route.link @ angular-route.js:985invokeLinkFn @ angular.js:8780nodeLinkFn @ angular.js:8280compositeLinkFn @ angular.js:7671publicLinkFn @angular。 js:7546name。$ get.boundTranscludeFn @ angular.js:7690controllersBoundTransclude @ angular.js:8307update @ angular-route.js:935 $ animate.link @ angular-route.js:900invokeLinkFn @ angular.js:8780nodeLinkFn @ angular.js :8280compositeLinkFn @ angular.js:7671publicLinkFn @ angular.js:7546 $ route.link @ angular-route.js:985invokeLinkFn @ angular.js:8780nodeLinkFn @ angular.js:8280compositeLinkFn @ angular.js:7671publicLinkFn @ angular.js:7546name 。$ get.boundTranscludeFn @ angular.js:7690controllersBoundTransclude @ angular.js:8307update @ angular-route.js:935 $ animate.link @ angular-route.js:900invokeLinkFn @ angular.js:8780nodeLinkFn @ angular.js:8280compositeLinkFn @ angular.js:7671publicLinkFn @ angular.js:7546 $ route.link @ angular-route.js:985invokeLinkFn @ angular.js:8 780nodeLinkFn @ angular.js:8280compositeLinkFn @ angular.js:7671publicLinkFn @ angular.js:7546name.$.get.boundTranscludeFn @ angular.js:7690controllersBoundTransclude @ angular.js:8307update @ angular-route.js:935 $ animate.link @ angular -route.js:900invokeLinkFn @ angular.js:8780nodeLinkFn @ angular.js:8280compositeLinkFn @ angular.js:7671publicLinkFn @ angular.js:7546 $ route.link @ angular-route.js:985invokeLinkFn @ angular.js:8780nodeLinkFn @ angular .js:8280compositeLinkFn @ angular.js:7671publicLinkFn @ angular.js:7546name。$ get.boundTranscludeFn @ angular.js:7690controllersBoundTransclude @ angular.js:8307update @ angular-route.js:935 $ animate.link @ angular-route。 js:900invokeLinkFn @ angular.js:8780nodeLinkFn @ angular.js:8280compositeLinkFn @ angular.js:7671publicLinkFn @ angular.js:7546 $ route.link @ angular-route.js:985invokeLinkFn @ angular.js:8780nodeLinkFn @ angular.js: 8280compositeLinkFn @ angular.js:7671publicLinkFn @ angular.js:7546name。$ get.boundTranscludeFn @ angular.js:7690c ontrollersBoundTransclude @ angular.js:8307update @ angular-route.js:935 $ animate.link @ angular-route.js:900invokeLinkFn @ angular.js:8780nodeLinkFn @ angular.js:8280compositeLinkFn @ angular.js:7671publicLinkFn @ angular.js: 7546 $ route.link @ angular-route.js:985invokeLinkFn @ angular.js:8780nodeLinkFn @ angular.js:8280compositeLinkFn @ angular.js:7671publicLinkFn @ angular.js:7546name./ get.boundTranscludeFn @ angular.js:7690controllersBoundTransclude @ angular .js:8307update @ angular-route.js:935 $ animate.link @ angular-route.js:900invokeLinkFn @ angular.js:8780nodeLinkFn @ angular.js:8280compositeLinkFn @ angular.js:7671 6angular.js:12450 RangeError:超出最大调用堆栈大小     在功能(本机)     在Object.ASTCompiler.compile

1 个答案:

答案 0 :(得分:0)

根据您提供的调用堆栈,看起来您的一个或多个页面模板包含ng-view指令。 ngRoute只允许在主布局页面中定义一个ng-view