简体   繁体   中英

How to read meta property of a document using AngularJS?

I am using AngularJS 1.6.3. I need to read meta properties of the Html document inside and AngularJS service.

<html>
<head>
    <meta name="keys" content="key1, key2"/>
    <!-- ... -->
</head>

Does AngularJS provide something like CookieService ($cookies) for Meta tags?

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. Something like this should work:

$document.head.querySelectorAll('meta')

Then loop over the items and find the one you are looking for.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM