简体   繁体   English

如何使用AngularJS读取文档的元属性?

[英]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.

相关问题 如何读取视口元标记的属性值? - How to read the property values of the viewport meta tag? 如何在AngularJS中读取Java属性文件? - How to read Java property file in AngularJS? 如何使用 AngularJS 使文档准备好条件? - How to make document ready conditional using AngularJS? 将angularJS与requireJS一起使用 - 无法读取未定义的属性“模块” - Using angularJS with requireJS - cannot read property 'module' of undefined 错误TypeError:无法读取未定义的属性&#39;名称&#39;-使用angularjs - ERROR TypeError: Cannot read property 'name' of undefined - Using angularjs 使用 AngularJS 和 Ionic 出现错误“TypeError:无法读取未定义的属性‘email’” - Error "TypeError: Cannot read property 'email' of undefined" using AngularJS and Ionic TypeError:无法使用AngularJS从数组读取未定义的属性“ 0” - TypeError: Cannot read property '0' of undefined from the Array using AngularJS 如何使用jQuery在页面上收听“元”属性更改? - How to listen to “meta” property change on the page using jquery? 如何在AngularJS中播种“无法读取null的属性&#39;reset&#39;”? - How Do I sove this “Cannot read property 'reset' of null” in AngularJS? 如何解决Angularjs TypeError:无法读取未定义的属性“ push”? - How to resolve Angularjs TypeError: Cannot read property 'push' of undefined?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM