2016-11-28 42 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

嘿謝謝...您的解決方案也適用於我。 –