How to load image (and other assets) in Angular an project?

前端 未结 8 1053
猫巷女王i
猫巷女王i 2020-11-29 03:14

I\'m pretty new to Angular so I\'m not sure the best practice to do this.

I used angular-cli and ng new some-project to generate a new app.

In

8条回答
  •  执念已碎
    2020-11-29 03:52

    1 . Add this line on top in component.

    declare var require: any
    

    2 . add this line in your component class.

    imgname= require("../images/imgname.png");
    
    1. add this 'imgname' in img src tag on html page.

提交回复
热议问题