合并声明'DepartmentListComponent'中的各个声明必须全部导出或所有local.ts(2395)路由组件

问题描述 投票:0回答:1

我对此代码有疑问,我完全按照视频教程(我正在学习)的方式来做,但是它不起作用,需要一些声明。指南中编写的代码是否可能采用某些较旧的方法?没有服务的硬代码。

app-routing.module.ts

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { DepartmentListComponent } from './department-list/department-list.component';
import { EmployeeListComponent } from './employee-list/employee-list.component';


const routes: Routes = [
  { path: 'departments', component: DepartmentListComponent },
  { path: 'employees', component: EmployeeListComponent }

];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule { }
export const routingComponents  [DepartmentListComponent, EmployeeListComponent ]

app.module.ts

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

import { AppRoutingModule, routingComponents } from './app-routing.module';
import { AppComponent } from './app.component';


@NgModule({
  declarations: [
    AppComponent,
    routingComponents
  ],
  imports: [
    BrowserModule,
    AppRoutingModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

app.component.html

<h1> Welocme in routing</h1>

<router-outlet></router-outlet>

我需要查看正在运行的应用程序,它们的URL格式为http://localhost:4200/employeeshttp://localhost:4200/departments。我是乞be,请谅解。

angular typescript routing
1个回答
0
投票

这里有同样的问题,甚至还有更奇怪的分辨率:删除出口线(最后一行)。编译(通常没有错误)再次添加最后一行。编译...做完了不要问我为什么。我也是初学者学习打字稿和Angular;-)

© www.soinside.com 2019 - 2024. All rights reserved.