Angular 2 中的一切都很好。但是,我升级到 4 的 beta 版本并在启动时收到 NoAnnotationError。我还没有服务,也没有注射剂。
这是我的代码:
应用程序.ts
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app.module';
platformBrowserDynamic().bootstrapModule(AppModule);
app.component.ts
require('./sass/index');
import 'zone.js';
import 'reflect-metadata';
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
template: `
<div class="app">
The Angular app has now loaded!
<router-outlet></router-outlet>
</div>`
})
export class AppComponent {
error: any;
showNgFor = false;
constructor ()
{
}
}
app.module.ts
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { HttpModule } from '@angular/http';
import { RouterModule } from '@angular/router';
import { AppComponent } from './app.component';
@NgModule({
imports: [
BrowserModule,
HttpModule,
RouterModule.forRoot([])
],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ]
})
export class AppModule { }
这是非常简单的东西......不确定我可能无法在此处注释的内容。
这是完整的错误:
Error: Cannot resolve all parameters for 'Parser'(?). Make sure that all the parameters are decorated with Inject or have valid type annotations and that 'Parser' is decorated with Injectable.