问题
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