Angular 2/typescript绑定文本从组件到index.html
问题描述:
如何将一个组件的变量绑定到index.html我想从一个组件传递/绑定一个var到一个组件在具体的index.html我想改变Angular 2/typescript绑定文本从组件到index.html
<meta property="og:title" content="" />
答
你可以尝试以下方法:
let ogTitleMeta = document.querySelector('meta[property="og:title"]');
ogTitleMeta.content = 'change content here!';
+0
var ogTitleMeta = document.querySelector('meta [property =“og:title”]'); ogTitleMeta.setAttribute('content','here new content') – Bas
答
这将做的工作:
var allMetaElements = document.getElementsByTagName('meta');
for (var i=0; i<allMetaElements.length; i++) {
if (allMetaElements[i].getAttribute("property") == "og:title") {
allMetaElements[i].setAttribute('content', 'change content here!');
}
}
你不能。你可以像使用JS一样使用typescript来更新标签。 –