3

我有一个角度应用程序,我决定在其中公开这个组件:

new ModuleFederationPlugin({
  
    // For remotes (please adjust)
    name: "app1",
    filename: "app1.js",
    exposes: {
         './Heroes': './/src/app/heroes/heroes.component.ts',
    },        

组件以这种方式呈现:

import { Component, OnInit } from '@angular/core';

@Component({
 selector: 'app-heroes',
 templateUrl: './heroes.component.html',
 styleUrls: ['./heroes.component.sass']
})
export class HeroesComponent implements OnInit {

  constructor() { }

  ngOnInit(): void {
 }
}

在我的主应用程序中,我想这样做:

<app-heroes></app-heroes>

如果组件是本地的,就像我会做的那样,如何实现这一点?理论上我必须:

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

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


@NgModule({
  declarations: [
   AppComponent,
   HeroComponent, //it's not local, so?
 ],
  imports: [
    BrowserModule,
    AppRoutingModule
  ],
   providers: [],
   bootstrap: [AppComponent]
})
 export class AppModule { }
4

0 回答 0