我尝试加载我的angular2应用程序,我收到此错误
虽然文件已到位。
我该如何解决这个问题?
app.component.ts
import {Component} from '@angular/core';
import {PushComponent} from '../../pages/push/push.component';
@Component({
selector: 'my-app',
template: '<h1>My 3rd Angular 2 App</h1> <push-comp></push-comp>',
directives: [PushComponent]
})
export class AppComponent {
}
和
app.module.js
import {NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {HttpModule} from '@angular/http';
import {AppComponent} from './app.component';
import {PushComponent} from '../../pages/push/push.component';
import {FormsModule} from '@angular/forms';
@NgModule({
imports: [BrowserModule, HttpModule, FormsModule],
declarations: [AppComponent, PushComponent],
bootstrap: [AppComponent]
})
export class AppModule {
}
答案 0 :(得分:0)
如果您使用@NgModules
,则无需导入推送组件和directives
中的属性AppComponent
。
app.component.ts
import {Component} from '@angular/core';
@Component({
selector: 'my-app',
template: '<h1>My 3rd Angular 2 App</h1> <push-comp></push-comp>'
})
export class AppComponent {
}