您无法获取命令行,但您可以使用左下角的输入字段添加包。
您可以在您选择的合适的 IDE 中创建一个项目,然后在您想提出问题时将其放入堆栈闪电战中。要与其他人一起开展项目,您应该使用 GitHub 之类的存储库。
这是一个使用和不使用单独路由模块的基本路由示例。
在 app.module.ts 中:
@NgModule({
declarations: [
AppComponent,
LoginComponent,
],
imports: [
BrowserModule,
AppRoutingModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
app-routing.module.ts 的基本示例:
const routes: Routes = [
// A simple route to a component
// Be aware that the order is important in angular
// The first route that fits the format will be used
{ path: 'login', component: LoginComponent },
]
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
或者你的 app.module.ts 没有单独的路由模块:
const routes: Routes = [
{ path: 'login', component: LoginComponent }
]
@NgModule({
declarations: [
AppComponent,
],
imports: [
BrowserModule
RouterModule.forRoot(routes)
],
providers: [],
bootstrap: [AppComponent]
})