gpt4 book ai didi

angular - 在 Angular 中加载 App 组件以外的另一个组件

转载 作者:搜寻专家 更新时间:2023-10-30 21:56:30 25 4
gpt4 key购买 nike

我想首先通过替换 Appcomponent 来加载 Angular 项目中的 FleshScreenComponent 组件,因此我正在这样做

 bootstrap: [FleshScreenComponent],

可是我还是做不到

因为我从 app.module.ts 文件中放入我的完整代码。

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

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

import { ReactiveFormsModule, FormsModule } from '@angular/forms';
import { HttpClientModule } from '@angular/common/http';
import { LoginComponent} from './LoginComponent/LoginComponent.component';
import { FleshScreenComponent} from './FleshScreenComponent/FleshScreenComponent.component';



@NgModule({
declarations: [
AppComponent,

LoginComponent,
FleshScreenComponent,


],
imports: [

],
entryComponents:[
LoginComponent, PaymentComponent
],
schemas: [ NO_ERRORS_SCHEMA ],
providers: [ServicesService ,CommonStorageService, {provide: MatDialogRef, useValue: {} }],
bootstrap: [FleshScreenComponent],

})
export class AppModule { }

最佳答案

看看 at this demo.

您需要在 index.html 中提供 FleshScreenComponent 的选择器,就像我在演示中为 HelloComponent 所做的那样

<hello>loading</hello>

关于angular - 在 Angular 中加载 App 组件以外的另一个组件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54651311/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com