Angular 4 Meta: add http-equiv dynamically

天涯浪子 提交于 2020-02-06 08:10:21

问题


Using Angular 4(5), I am trying to add a meta tag dynamically, specifically this tag:

<meta http-equiv="X-UA-Compatible" content="IE=edge">

So in Angular, I am doing this:

constructor(private meta: Meta) {
    this.meta.addTag({ httpEquiv: 'X-UA-Compatible', content: 'IE=edge' });
}

However, the above renders 'http-equiv' NOT hyphenated, like this:

<meta httpequiv="X-UA-Compatible" content="IE=edge">

How do I get Angular to render the proper http-equiv meta tag attribute?


回答1:


Try that

this.meta.addTag({ name: 'http-equiv', content: 'IE=edge' });



回答2:


try this

this.meta.addTag({'http-Equiv': 'X-UA-Compatible', content: "IE=edge"});



回答3:


It seems the proper way is:

meta.addTag({httpEquiv: 'Content-Type', content: 'text/html'}); 

https://www.concretepage.com/angular/angular-meta-service-for-meta-tags



来源:https://stackoverflow.com/questions/48672444/angular-4-meta-add-http-equiv-dynamically

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!