-1

In the header component, I needed to add a logo image, so I wrote the following in HTML:

header-component.html

<div class="col-md-4 text-left">
  <a routerLink="/">
      <img id="logo" src="../images/header/Logo.png"
        alt="logo"/>
  </a>
</div>

But browser can not see the logo, it just shows the default picture image. I checked it with the system administrator, there are no network problems. Can anyone help?

4
  • Try adding the image's directory path in angular.json's assets array and then use the image name just like 'assets/images-name.png' Commented May 20, 2022 at 10:31
  • try to find real link where the logo is working, and check the real url Commented May 20, 2022 at 10:31
  • Do you have any error in console? Have you added in the assets array in your angular.json file the path to that image's folder? Commented May 20, 2022 at 10:34
  • @JacopoSciampi Yes, assets are added in angular.json. I have an error "GET localhost:4200/images/header/Linkedin.png 404 (Not Found)" Commented May 20, 2022 at 10:45

2 Answers 2

0

Does not work because your own resource providers has to be included in angular.json, assets is included by default, why are you separating images from assets? Just create images folder inside assets and call it like assets/images/logo.png

Sign up to request clarification or add additional context in comments.

Comments

0

To make file publicly available in angular you have to place it it assets folder. Also bear in mind that in Angular projects, you don't have to add the relative to assets folder. In your case "assets/images/header/Logo.png" will be enough.


You can relocate your assets folder in angular.json if needed

"assets": [
    "src/assets"
 ],

8 Comments

I tried already, but it does not work. path is 100% right
Then try moving the image folder into assets folder. Since angular gives public access to this folder.
Thanks, but it does not works
Once you move image inside assets folder, you will have to update the image path just like 'assets/images-name.png'. Did you update the img tag's src path?
@Krishna Yes, I updated
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.