ngx-favicon is an Angular service to dynamically update the favicon on your web app.
favicon generator, angular change favicon dynamically, angular favicon not updating, create react app favicon, how to change favicon html, how to change favicon in angular 10
Simple Javascript Library To Change The Favorite Page Icon | favicon.js
How to make use of it:
Install the library in your project:
npm i ngx-favicon
1. Put your favorite icon(s) somewhere in your project and don’t forget to add it to your angular.json file:
{ ... "projects": { "[YOUR PROJECT NAME]": { ... "architect": { ... "build": { ... "options": { ... "assets": [ "src/favicon.ico", + "src/favicon-success.ico", + "src/favicon-error.ico", "src/assets" ], } } } } } }
2. Create a new file called favicon.config.ts and enter the following code in it:
// enum all your different favicons // (for type safety) export enum CustomFavicon { FAVICON_SUCCESS = 'faviconSuccess', FAVICON_ERROR = 'faviconError', } export type AvailableCustomFavicons = { [key in CustomFavicon]: string }; // ------------------------------------------------------------- // @warning do not forget to add your favicons to your bundle // you should double check into angular.json file // ------------------------------------------------------------- // map all the types of favicon to their href export const customFavicons: AvailableCustomFavicons = { // for some reason, impossible to use the syntax // [CustomFavicon.FAVICON_SUCCESS]: 'favicon-success.ico', // otherwise we end up with an AOT ERROR faviconSuccess: 'favicon-success.ico', faviconError: 'favicon-error.ico', };
3. Open the index.html file and add an identifier to the link tag specifying the favicon:
<app-root></app-root>
4. Import the NgxFaviconModule using the forRoot method and select your configuration only once:
+ import { NgxFaviconModule } from 'ngx-favicon'; + import { customFavicons, AvailableCustomFavicons } from './favicon.config'; @NgModule({ ... imports: [ ... + NgxFaviconModule.forRoot<AvailableCustomFavicons>({ + faviconElementId: 'favicon', + defaultUrl: 'favicon.ico', + custom: customFavicons, + }), ], providers: [], bootstrap: [AppComponent], }) export class AppModule {}
Update Favicon On App, NgxFaviconDemo Plugin/Github
See Demo And Download
Official Website(cloudnc): Click Here
This superior jQuery/javascript plugin is developed by cloudnc. For extra Advanced Usages, please go to the official website.