Angular-2 : Change favicon icon as per configuration

前端 未结 6 1578
你的背包
你的背包 2021-01-31 09:53

I am rendering a dynamic page, menu and other items in my application. I also want to change favicon as per configured by admin.

Say, for example, if when my pag

6条回答
  •  佛祖请我去吃肉
    2021-01-31 10:42

    In index.html set link tag

    
    

    and somewhere in your code import

    import { Component, Inject } from '@angular/core';
    import { DOCUMENT } from '@angular/common';
    
    constructor(@Inject(DOCUMENT) private _document: HTMLDocument) {}
    

    and use it like this

    this._document.getElementById('appFavicon').setAttribute('href', '/your/icon/path.ico');
    

    Angular 5.0 <

    import { DOCUMENT } from '@angular/platform-browser';
    

提交回复
热议问题