[英]How to read meta property of a document using AngularJS?
I am using AngularJS 1.6.3. 我正在使用AngularJS 1.6.3。 I need to read meta properties of the Html document inside and AngularJS service. 我需要阅读Html文档的内部属性和AngularJS服务。
<html>
<head>
<meta name="keys" content="key1, key2"/>
<!-- ... -->
</head>
Does AngularJS provide something like CookieService ($cookies)
for Meta tags? AngularJS是否为Meta标签提供类似CookieService ($cookies)
东西?
There isn't any core service that implements what you are looking for. 没有任何核心服务可以实现您想要的东西。 You will need to use the $document
service and look for the meta tags you want. 您将需要使用$document
服务并查找所需的元标记。 Something like this should work: 这样的事情应该起作用:
$document.head.querySelectorAll('meta')
Then loop over the items and find the one you are looking for. 然后遍历所有项目,找到您要的项目。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.