我正在做快速入门教程,遇到一些错误。下面是我的文件结构:
//## home/home.component.ts #################
import {Component} from '@angular/core';
@Component({
selector:'home',
template: `
<div>I'm a home component.</div>
`
})
export class HomeComponent{}
//## home/home.module.ts #################
import {NgModule} from "@angular/core";
import {HomeComponent} from "./home.component";
NgModule({
declarations: [HomeComponent],
exports: [HomeComponent]
});
export class HomeModule {
}
//## app.component.ts #################
import {Component} from "@angular/core";
@Component({
selector: 'app',
template: `
<div>I'm the App Component</div>
`
})
export class AppComponent {}
//## app.module.ts #################
import {AppComponent} from "./app.component";
import {BrowserModule} from "@angular/platform-browser";
import {NgModule} from "@angular/core";
import {HomeModule} from "./home/home.module"; //this breaks it
@NgModule({
declarations: [AppComponent],
bootstrap: [AppComponent],
imports: [BrowserModule, HomeModule] //home module breaks it
})
export class AppModule{}
//## main.ts #################
import {platformBrowserDynamic} from "@angular/platform-browser-dynamic";
import {AppModule} from "./app.module";
platformBrowserDynamic().bootstrapModule(AppModule);我很困惑,因为这是一个非常简单的例子。Home模块以某种方式导致应用程序失败。它会显示以下错误:
ZoneAwareErrormessage: "(SystemJS) Cannot set property 'stack' of undefined ...后面跟着几百行相同的代码。有没有人对如何调试这样的错误有什么想法?
发布于 2017-01-14 02:27:02
我不能解决这个问题,但是对于任何遇到同样问题的人,请避免使用快速入门教程,而使用angular-cli来生成东西。在开始的时候,它看起来更清晰,更容易理解。
ng new new-project --style=sass会帮你排忧解难的。
发布于 2017-01-13 10:05:04
如果HomeModule是一个功能模块,请将声明部分更改为declarations: [CommonModule, HomeComponent]
发布于 2017-01-13 17:30:01
我得到了同样的错误,这是因为区域在我的模板中发现了一些错误。我在Angular 2.4.1和0.7.4区域,尝试升级。
顺便说一句,我已经将模板属性设置为我的模板的url,这是工作,所以,我认为专区可能有一个bug或什么。
https://stackoverflow.com/questions/41621895
复制相似问题