简体   繁体   中英

how to use existing component in the dynamic loaded module component in angular

is it possible to use loaded components with app.module.ts in dynamic future loading components using loadClildren as a tag?

I have a SharedTag component and declared in app.module and loaded when the bootstrap happen.

<shpared-tag></shared-tag>

I have another search component which will loaded dynamically as below.

  {
    path: 'search/:searchText',
    loadChildren: 'app/search/search.module#SearchModule'
  }

But when I try to use <shpared-tag></shared-tag> in dynamically loaded search component, it says shared-tag component is not available. But this component is already loaded with the app.module and available in the browser.

In case of angular-cli and webpack build this problem is resolved, you don't need to worry about the future component.

Webpack module loader to find the module and load them in the browser.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM