How could I use a system.import() into component angular 2

前端 未结 2 1424
傲寒
傲寒 2021-01-17 12:51

I saw in this post that you can use SystemJS to load external javascript files into my components in Angular 2.

In my index.html :



        
2条回答
  •  不思量自难忘°
    2021-01-17 13:12

    You can use systemjs to do your external dependency loading.

    npm i systemjs --only=dev
    npm i @types/systemjs --only=dev
    

    You'll need to update your tsconfig.app.json file (tsconfig.json file for older versions of Angular).

    "types": ["systemjs"]
    

    Now you'll be able to import

    System.import("your-url").then(response => response.methodCall());
    

    If you have an import map specified

    
    

    You can instead call this code

    System.import("import-name").then(response => responce.methodCall());
    

提交回复
热议问题