首页 文章

带有templateUrl的Angular2 RC5无限循环

提问于
浏览
0

我对Angular2 RC5有问题 .

我的app.component(由app.module引导)看起来像这样,非常基本:

@Component({
    selector: 'my-app',
    template: `TEST`
})

export class AppComponent implements OnInit {

    constructor() {
        console.log("APP LOG!");
    }

    ngOnInit() {
        console.log("APP INIT LOG!");
    }

}

只要我在组件内部编写模板,它就可以正常工作 . 但是当我将它转移到自己的html文件并通过它包含它

templateUrl: 'app.component.html'

我遇到了一个无限循环 . 一遍又一遍地调用构造函数,从不到达ngOnInit . 无论我是尝试相对还是绝对路径都没有区别 . 没有ngModules在RC4上没有这个问题 .

相应的ngModule,也很基本:

@NgModule({
imports: [
    BrowserModule
],
declarations: [
    AppComponent
],
bootstrap: [AppComponent]
})
export class AppModule {}

我使用Meteor,所以一切都是使用Meteor angular2编译器编译的 .

任何提示都非常感谢!

1 回答

相关问题