【发布时间】:2018-06-19 06:23:05
【问题描述】:
我使用下面的代码在运行时在 angular5 中添加或更新元标记
import { Title ,Meta} from '@angular/platform-browser';
constructor( private meta:Meta)
{
this.meta.addTags([
{name: 'description', content: 'How to use Angular 4 meta
service'},
{name: 'author', content: 'talkingdotnet'},
{name: 'keywords', content: 'Angular, Meta Service'}
]);
this.meta.updateTag({ name: 'description', content: 'Angular 4 meta service'
});
}
在 appmodule 中导入元服务
但它不起作用(不在我的页面源中)。任何人都可以帮助我
谢谢
【问题讨论】:
-
遇到任何错误?
-
尝试将此代码添加到您的根组件 .ts 文件中
-
没有错误。但元中没有更新
标签: javascript angular angular5