Angular 2 Image not displaying

So I have a very simple problem.

Images are not displayed in my Angular 2 application.

This is how I define the image:

<img alt="logo" [src]="'./images/logo.png'">

Is there some kind of package that I have to install to create images?

BTW I'm new to Angular, as you probably can guess!

0
source share
3 answers

Property Binding ('[]'): Set the property of a view element to the value of a template expression.

<img alt="logo" src="'./images/logo.png'">
Run code

just works great

+1
source

If your image URL is a known value, as you seem to point out here, there is no need for a special binding of the angular property.

, HTML:

<img alt="logo" src="images/logo.png">

, -

0

you need to install an image downloader

Try file-loader , then you should add these rules to your web package

    module.exports = {
  module: {
    rules: [
      {
        test: /\.(png|jpg|gif)$/,
        use: [
          {
            loader: 'file-loader',
            options: {}  
          }
        ]
      }
    ]
  }
}

he should work now

0
source

All Articles