2016-11-05 84 views
0

(第一篇文章曾經..對不起任何錯誤)CLOSED - angular2語義UI下拉路線上改變失敗

我一直在Angular2和語義的UI下拉玩耍。 我已經失去了我的想法,因爲它已經兩天了,我不知道這個問題。

我有分量「dropdown.component」,當它運行ngAfterViewInit它調用

//////////////////// 
// dropdown.component 
//////////////////// 
ngAfterViewInit(){ 
    this.dom.loadDrop($(this.elementRef.nativeElement).find('select')); 
} 
ngOnDestroy(){ 
//I am doing the .dropdown('destroy') -- although this will only disable. 
//Could not find nothing to unbind the dropdown. 
} 

//////////////////// 
//inside dom class 
//////////////////// 
loadDrop(elm: any) { 
    if (typeof (elm) === 'string') { 
     elm = $(elm); 
    } 
    $(document).ready(function() { 
     elm.dropdown({ allowAdditions: true }) 
    }); 
} 

這完美的作品,當我重新加載頁面上的第一次(一個或多個dropdown.component),儘管當我使用router.navigate訪問一個頁面時,routerLink或者簡單地回到dropdown.component存在的頁面,瀏覽器在嘗試初始化第一個下拉菜單後會凍結。

任何想法或指導方針?

(謝謝)

回答

0

終於!!

下拉菜單完美。問題是我正在應用一個Pipe來將枚舉值轉換爲值(因爲某些原因導致它失敗)。

每當它進入包含Enum下拉列表的頁面時,它都會失敗。