我有一个角度最终应用程序,可以加载很多路径和模块。我开始在控制台中收到“区域已加载”错误,现在我得到它两次。
我查看了区域对象,试图弄清楚发生了什么,但是如果不知道应该做什么区域,这几乎是不可能解密的。
Main.ts
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { environment } from './app/';
import {AppModule} from './app/app.module';
enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule,[]);
app.module.ts(我省略了所有导入):
@NgModule({
imports: [ BrowserModule, RouterModule.forRoot(appRoutes), SharedModule.forRoot(),
HomeModule, DocumentsModule, AboutModule, SettingsModule, FoodModule, CalculatorModule,
ThemesModule ],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ],
providers: [ appRoutingProviders ]
})
export class AppModule {}
app.component.ts
@Component({
moduleId: module.id,
selector: 'kg-root',
templateUrl: 'app.component.html',
styleUrls: ['app.component.css']
})
export class AppComponent implements OnInit {
private items: MenuItem[];
appPageHeaderDivStyle: {};
selectedTheme: Theme;
errorMessage: string;
loggedIn: LoggedIn;
loggedInEmail: string = "";
isLoggedIn: boolean;
constructor(
private as: AppMenuService,
private ts: ThemeService,
private ss: SettingsService,
private ls: LoginService) {
}
ngOnInit() {
this.ts.getNewTheme()
.subscribe(
theme => this.selectedTheme = theme,
error => {
this.errorMessage = error
},
() => this.completeGetNewTheme()
);
this.ts.setTheme("Pepper-Grinder");
this.items = this.as.getNoLoginMenu();
this.ls.getLoggedIn()
.subscribe(
loggedIn => {
if (loggedIn.error != undefined && loggedIn.error === "" && loggedIn.email != "") {
this.items = this.as.getLoggedInMenu();
var us = this.ss.getUserSettings();
if (us != undefined && us.theme != null && us.theme != "") {
this.ts.setTheme(us.theme);
}
}
else {
this.items = this.as.getNoLoginMenu();
this.ts.setTheme("Pepper-Grinder");
}
this.completeLoggedIn(loggedIn.email);
});
}
completeLoggedIn(email: string) {
this.loggedInEmail = email;
this.isLoggedIn = (this.loggedInEmail.length > 0);
}
completeGetNewTheme() {
this.appPageHeaderDivStyle = this.ts.getAppPageHeaderDivStyle();
}
答案 0 :(得分:2)
我认为这个错误意味着已经加载了一些给定的区域。看来这意味着" zone.js"已经装好了。当我切换到Angular-cli时,它已经加载到angular-cli-build.js中。所以从index.html中删除它解决了这个问题。
我发布此邮件以防其他人遇到错误。