Open Closed

Reuse Blazor component from service A in service B #7301


User avatar
0
carl.hallqvist created
  • ABP Framework version: v7.3.3
  • UI Type: Blazor WASM
  • Database System: EF Core (SQL Server)
  • Tiered (for MVC) or Auth Server Separated (for Angular): yes
  • Exception message and full stack trace:
  • Steps to reproduce the issue:

Hi,

Can you please guide me of how to include a Blazor component from service A in service B?

In service A (CustomerService) we have a lot of CRUD forms as dialog components that we would like to reuse in service B (ProductService).

Can you please guide me?

Thanks, Carl


8 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    You can create a shared project and place components to reuse the Blazor components.

    For example:

    Component.Shared project:

    DialogAComponent

    <p>This is a reuse Blazor component<p>
    

    Service A project

    Service A Index page
    <DialogAComponent/>
    

    Service B project

    Service B Index page
    <DialogAComponent/>
    
  • User Avatar
    0
    carl.hallqvist created

    Thanks,

    Do you have some example of how to do it? How to do deal with components that using AppServices? The shared project needs to be using AppServices I guess to be able to do CRUD operations?

    Kind regards, Carl

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    The shared project can reference to the application project.

  • User Avatar
    0
    carl.hallqvist created

    Ok, but why it is not possible to reference service a in service b? It is just the front-end client I mean. Bad practice or any other technical issues? In some projects I have seen only one big Blazor project, that communicate with the gateway. ABP MicroService have one top Blazor app, referencing to other Blazor project in the different services.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Yes you can.

    But I recommend you create a shared project

  • User Avatar
    0
    carl.hallqvist created

    Hi,

    Yes you can.

    But I recommend you create a shared project

    Thanks, I understand but not the reason. Can you tell me please? :-)

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Because creating shared projects allows for better reuse of components, you may have other services that need to use these components in the future.

  • User Avatar
    0
    carl.hallqvist created

    Thanks, I got you and seems reasonable.

Made with ❤️ on ABP v9.1.0-preview. Updated on November 01, 2024, 05:35