1

I've done my research and found one or two answers explaining that I'm supposed to define my file in the assets section of angular-cli.json file. I've done it as follows.

"assets": [
  "assets",
  "mylogo.png",
  "favicon.ico"
],

Later on, in the template I do the following.

<img src="mylogo.png">
<img src="favicon.ico">

The first one shows as a broken link whereas the second (the default Angular icon) shows just fine. I can't understand it as both reside in the same directory and both are referred to in the configuration file.

What am I missing?

DonkeyBanana
  • 3,266
  • 4
  • 26
  • 65
  • You probably have another `favicon.ico`. Also favicons tend to get cached longer than other assets. Inspect the build with developer tools to se where the `mylogo.png` is actually point at. – Lazar Ljubenović Jan 04 '18 at 14:20
  • @LazarLjubenović Could you elaborate the inspection part, please? How do I do that? I can see the console output saying that *http://localhost:4200/mylogo.png* is 404 but more than that, I'm lost... – DonkeyBanana Jan 04 '18 at 14:22

1 Answers1

2

I had the same Problem, but i wanted to display an custom Icon. My Solution was deleting the facicon.ico and the decleration in .angular-cli.json.

"assets": [
  "assets",
  "house.png"
 ],

My implementation in HTML index.html

<link rel="icon" type="image/x-icon" href="house.png" />

The implemented custom Icon

Then Restart your Application.

Moritz Vogt
  • 99
  • 1
  • 9
  • 1
    It might be that the *ng serve* needs to be reexecuted (at least in some browsers/OSs). Also, it might help to clean the cache, just in case. – DonkeyBanana Jan 08 '18 at 19:02