Update meta tags in angular universal with external API call

后端 未结 4 1981
庸人自扰
庸人自扰 2020-12-30 12:02

I\'ve spent more than 2 months but could not found a clear solution of how to proceed with angular universal. I\'ve already spent about 6 months in implementing angular univ

4条回答
  •  庸人自扰
    2020-12-30 12:31

    I implemented setting title on Angular 2 Universal. It should be done using Renderer, like this:

    1.Import Renderer inside of component:

    import {Renderer } from '@angular/core';
    

    2.Add dependency inside of constructor:

    constructor
        (
            ...
            private renderer: Renderer
        ) {}
    

    3.Use it now for setting title:

    renderer.setText(renderer.selectRootElement('title'), value);
    

提交回复
热议问题