CLOSED - angular2 semantic-ui下拉列表在路由更改时失败

时间:2016-11-05 16:51:24

标签: angular dropdown semantic-ui angular-routing routerlink

(第一篇文章......对任何错误感到抱歉)

我一直在玩Angular2和Semantic-UI下拉列表。 我已经失去了理智,因为已经有两天了,我无法弄清楚问题。

当它运行它调用的ngAfterViewInit时,我有一个组件“dropdown.component”

////////////////////
// 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访问页面时,或者做一个简单的回到下拉页面。组件存在,浏览器在尝试初始化第一个下拉列表后冻结。

任何想法或指导方针?

(感谢)

1 个答案:

答案 0 :(得分:0)

最后!!

Dropdown完美无缺。问题是我正在应用一个Pipe来转换值上的枚举(由于某种原因,这会使它失败)。

每次进入包含Enum下拉列表的页面时都会失败。