0

无法解决这个问题。我的 app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppRoutingModule } from './app-routing.module';
import { HttpClientModule } from '@angular/common/http';

import {NoopAnimationsModule} from '@angular/platform-browser/animations';
import {MatButtonModule,
                MatCheckboxModule,
                MatSidenavModule,
                MatToolbarModule,
                MatListModule,
              MatDialogModule,
              MatInputModule,
            MatSnackBarModule} from '@angular/material';

import {FormsModule, ReactiveFormsModule} from '@angular/forms';

import { AppComponent } from './app.component';
import { ProjectResourceComponent } from './project-resource.component';
import { ProjectsComponent } from './projects.component';
import { StatusComponent } from './status.component';
import { TaskComponent, DialogOverviewExampleDialog } from './task.component';

import { FirstComponent } from './first.component';
import { ProjectsList } from './first.component';

import { GetProjectList } from './master.service';

import { FilterPipe } from './filter.pipe';
import { TaskDetailComponent } from './task-detail.component';



@NgModule({
  declarations: [
  AppComponent,
    FirstComponent,
    ProjectResourceComponent,
    ProjectsComponent,
    StatusComponent,
    TaskComponent,
  FilterPipe,
    DialogOverviewExampleDialog,
    TaskDetailComponent
  ],
  imports: [
  BrowserModule,
    HttpClientModule,
    NoopAnimationsModule,
    AppRoutingModule,
    MatButtonModule,
    MatCheckboxModule,
    MatSidenavModule,
    MatToolbarModule,
    MatListModule,
    MatDialogModule,
    FormsModule,
    ReactiveFormsModule,
    MatInputModule,
    MatSnackBarModule

  ],
    entryComponents: [
        DialogOverviewExampleDialog
    ],
  providers: [GetProjectList,
              ProjectsList],

  bootstrap: [AppComponent]
})
export class AppModule { }

我的应用程序-routing.module.ts

    import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { RouterModule, Routes } from '@angular/router';

import { FirstComponent } from './first.component';
import { ProjectResourceComponent } from './project-resource.component';
import { ProjectsComponent } from './projects.component';
import { TaskComponent } from './task.component';
import { StatusComponent } from './status.component';
import { TaskDetailComponent } from './task-detail.component';

const routes: Routes = [
 {path: '' , redirectTo: '/first', pathMatch: 'full' },
  { path: 'first', component: FirstComponent,
    children: [
    {path: '', component:ProjectsComponent},
    { path: 'resource', component: ProjectResourceComponent },
    { path: 'project', component: ProjectsComponent },
    { path: 'task', component: TaskComponent
  // ,
  //   children:[
  //     { path: 'taskDetail', component: TaskDetailComponent}
  //   ]
   },
    { path: 'status', component: StatusComponent },
  { path: 'taskDetail', component: TaskDetailComponent}
]
  }
  // { path: 'resource', component: ProjectResourceComponent },
  // { path: 'project', component: ProjectsComponent }
];

@NgModule({
  imports: [
//    CommonModule
RouterModule.forRoot(routes)],
  exports: [ RouterModule ],
  declarations: []
})
export class AppRoutingModule { }

我是Angular2的新手。我一添加 task-detail.component.ts 和 task-detail.coponent.html 就收到此错误。

我不确定路由或其他问题出在哪里

早些时候它工作正常

无法弄清楚这个错误

compiler.es5.js:1694 Uncaught Error: Unexpected value 'undefined' declared by the module 'AppModule'
    at syntaxError (compiler.es5.js:1694)
    at compiler.es5.js:15430
    at Array.forEach (<anonymous>)
    at CompileMetadataResolver.webpackJsonp.../../../compiler/@angular/compiler.es5.js.CompileMetadataResolver.getNgModuleMetadata (compiler.es5.js:15428)
    at JitCompiler.webpackJsonp.../../../compiler/@angular/compiler.es5.js.JitCompiler._loadModules (compiler.es5.js:26826)
    at JitCompiler.webpackJsonp.../../../compiler/@angular/compiler.es5.js.JitCompiler._compileModuleAndComponents (compiler.es5.js:26799)
    at JitCompiler.webpackJsonp.../../../compiler/@angular/compiler.es5.js.JitCompiler.compileModuleAsync (compiler.es5.js:26728)
    at PlatformRef_.webpackJsonp.../../../core/@angular/core.es5.js.PlatformRef_._bootstrapModuleWithZone (core.es5.js:4536)
    at PlatformRef_.webpackJsonp.../../../core/@angular/core.es5.js.PlatformRef_.bootstrapModule (core.es5.js:4522)
    at Object.../../../../../src/main.ts (main.ts:11)

请帮忙...

4

0 回答 0