2016-11-28 56 views
1

我遇到了ng2-bootsrap传送带的问题。当页面中的轮播代码被注释掉时,页面(/ home2)会正常加载。但是,当轮播代码运行时,浏览器将一直等待服务器为页面提供服务(服务器永远不会),导致页面为空。仅供参考,我正在使用Angular Universal Starter项目。从ng2-bootstrap传送带引起Angular Universal陷入循环

这里是在HOME2部件转盘代码myInterval集5000:

<carousel [interval]="myInterval" [noWrap]="noWrapSlides"> 
      <slide *ngFor="let slidez of slides;let index=index" [active]="slidez.active"> 
       <!-- <img [src]="slidez.image">--> 
       <div class="carousel-caption"> 
        <h4>Slide {{index}}</h4> 
        <p>{{slidez.text}}</p> 
       </div> 
      </slide> 
      <i class="fa fa-chevron-left left carousel-control"></i> 
      <i class="fa fa-chevron-right right carousel-control"></i> 
     </carousel> 

这里是关于服务器侧的输出(表示):

GET /home2 - - ms - - 
inside ngApp 
/home2 
GET /home2 - - ms - - 
nginside ngApp 
/home2 
GET /home2 - - ms - - 
inside ngApp 
/home2 
GET /home2 - - ms - - 

这里是控制台日志在服务器上的语句:

function ngApp(req, res) { 
    console.log("inside ngApp"); 
    console.log(req.originalUrl); 
    res.render('index', { 
    req, 
    res, 
    // time: true, // use this to determine what part of your app is slow only in development 
    preboot: false, 
    baseUrl: '/', 
    requestUrl: req.originalUrl, 
    originUrl: `http://localhost:${ app.get('port') }` 
    }); 
} 

在我看来,Angular Universal陷入循环。 这里是执行:interior design ideas与禁用的时间间隔,以避免无限循环。如果有人能告诉我如何解决这个问题,我将不胜感激。 任何建议将不胜感激。

感谢

+0

嘿..如果你有答案请在这里更新。我也陷入了这个问题。 thankx –

回答

1

我有同样的问题,但发现解决方案,NG2,引导使用浏览器元素,需要等到客户端应用程序引导你必须创建自己的旋转木马兼容通用或* ngIf等到引导你必须在组件检查以下代码:

import {isBrowser} from "angular2-universal"; 

if (isBrowser) { 
    //example 
    this.showCarousel = true; 
} 
+0

嘿谢谢...您的解决方案也适用于我。 –