0

创建新的角度组件后出现此错误,创建后我在 app.module.shared.ts 上定义了它:

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ReactiveFormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { RouterModule } from '@angular/router';

import { AppComponent } from './components/app/app.component';
import { NavMenuComponent } from './components/navmenu/navmenu.component';
import { HomeComponent } from './components/home/home.component';
import { HistoryGridComponent } from "./components/history/histories-grid.component";

@NgModule({
    declarations: [
        AppComponent,
        NavMenuComponent,
        HomeComponent,
        HistoryGridComponent
    ],
    imports: [
        CommonModule,
        HttpModule,
        ReactiveFormsModule,
        RouterModule.forRoot([
            { path: '', redirectTo: 'home', pathMatch: 'full' },
            { path: 'home', component: HomeComponent },
            { path: 'history', component: HistoryGridComponent },
            { path: '**', redirectTo: 'home' }
        ])
    ]
})
export class AppModuleShared {
}

并试图运行,但它总是返回以下错误:

错误

关于正在发生的事情有什么想法吗?

4

1 回答 1

0

我认为您删除了 history-grid 文件夹中的 history-grid.component.html。如果您这样做了,请删除 history-component.ts 的 @Component 中的“templateUrl”属性 在此处输入图像描述

于 2017-11-04T07:27:31.897 回答