0

i just started with Angular and tried to something (i thought) would be realy simple and a good start: Changing the icon for the tab.

What i assumed was that Angular would just need to know where the icon is and where to put it. So i followed this: How to change Angular CLI favicon

Simply replacing "favicon.ico" with the selfmade "favicon2.ico"

This lead to the result that nothing at all is shown. So, i tried a few things like making it smaler (32x32), different colour etc... still nothing does show up. I also had to learn that Angular seems to use code randomly (sometimes new code, sometimes old, i dont even know where the programm gets the old code from since i deleted everything and restarted everything including the compiler).

However, i then tried a simpler approach: I just changed "favicon.ico" itself and undid everything i did before. This is where it got really weird: It now uses the old icon (which should not even exist anymore) and inspecting the page does show really old code that has nothing to do with what is shown (telling me its using favicon2.ico). Visual Studio does confirm that "favicon.ico" has been changed.

My conclusion is that the "favicon.ico" in the src folder has no real purpose and the actual icon does come from somewhere else?

An other thing for me would be to at least somehow make sure that Angular does use the current code and never jumps back to code that should not even exist anymore. This is frustrating me the most.

I would show my code but it really is just the demo page and i changed the "favicon.ico".

Thank you very much for your help.

  • Maybe explain us you run/build your code. But everything you say sounds like you have an issue in the way you run your code, not the code itself. – Gaël J Sep 05 '21 at 17:48
  • 1. Create a new project in the cmd: 'ng new my-app' 2. Go to the new folder in the cmd: 'cd my-app' 3. Compile the project in the cmd: 'ng serve --open' (Up to this point it seems to be okay it just tells me it cant find "git") 4. Create "favicon2.ico" with gimp (32x32) and save it in the src folder (it does show up in Visual Studio directly under "favicon.ico"). 5. Change "favicon.ico" in "index.html" to "favicon2.ico. 6. Change "favicon.ico" in "angular.json" to "favicon.ico". 7. Save. – Der Sten Sep 05 '21 at 19:02
  • It can be worth relaunching `ng serve` after some changes but otherwise your process seems ok. You should not see any old code. Are you sure your IDE saves the file when you think it does? – Gaël J Sep 05 '21 at 19:07
  • I restarted my entire computer. "favicon2.ico" is still shown even while neither the file nor the code for it does exist. It does work now (for some reason), only inspecting the page does show old and none existing code/files. – Der Sten Sep 09 '21 at 18:30

1 Answers1

0

Clearing cache might help

Clear Cache Shortcuts: (Source)

Windows IE:Ctrl+R; Firefox:Ctrl+Shift+R; Chrome:Ctrl+R, or Ctrl+F5, or Shift+F5.

Mac Safari:⌘+R; Firefox/Chrome:⌘+Shift+R.

Suraj Rawat
  • 3,685
  • 22
  • 33
  • Thank you very much, i seemed to make changing the icon possible. However the code is still selected in an unpredictable pattern. Inspecting the page does show this: '' this code does not exist anymore, since i changed it back to "favicon.ico" and even deleted "favicon2.ico". "favicon.ico" is also what is shown in the actual tab. Angular is very confusing. Why does it not work like this "actual code" = "code used in the tab" = "code that is shown when inspecting the tab"? – Der Sten Sep 05 '21 at 18:54
  • Not at all. It's not confusing. Did you rebuild your project again ? – Suraj Rawat Sep 05 '21 at 18:59
  • I restarted everything. The project and then the computer, after some messing around, it does work. Inspecting the page does still show old code from before restarting the computer. As long as this code is not realy used, its okay, i guess? I am really thankfull for your help but a program that does use old code (which is at least more or less inaccessible) is very confusing. I have never seen this behaviour before. – Der Sten Sep 09 '21 at 18:59