Get and download the remote component / module in angular 4.4 application

Here is what I'm trying to achieve: I want to create an application using "plugins", through plugins I mean:

Another angular component / module that can be deployed to a remote host and displayed in my application.

It seems like I can't do this with webpack directly and that I should use SystemJs to dynamically load the module.

Any tips you can use to use SystemJs and Webpack (ng cli), examples of how to call the remote module and load them.

+1
source share
2 answers

, systemjs angular -cli . componentFactoryResolver , . systemjs , :

npm i systemjs

angular-cli.json:

"scripts": [
    "../node_modules/systemjs/dist/system.src.js"
],

scripts.js :

systemjs, . :

declare var SystemJS;

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  constructor() {
    SystemJS.load(...);
  }

, SystemJS , . Angular.

+2

Source: https://habr.com/ru/post/1683262/


All Articles