webpack not able to import images( using express and angular2 in typescript)

前端 未结 7 1497
难免孤独
难免孤独 2020-12-09 04:00

I am not able to import images in my headercomponent.ts. I suspect it is because of something i am doing wrong while compiling ts(using webpack ts loader) because same thin

7条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-09 04:35

    I also had same issue so I used following approach:

    import * as myImage from 'path/of/my/image';
    

    In my component I simply assigned the imported image to a data member;

    export class TempComponent{
        public tempImage = myImage;
    }
    

    and used it in template as:

    blah blah blah
    

提交回复
热议问题