Answer the question
In order to leave comments, you need to log in
How to implement Angular SEO, meta tags for sharing (facebook, vk)?
Good afternoon, I ran into such a problem: it is necessary to share (both using the share button and copy-paste url) links in vk and facobook with beautiful posters and the right titles. This is usually implemented using meta tags:
...
<meta property="og:title" content="" />
<meta property="og:image" content="" />
...
...
<meta property="{{meta.property}}" content="{{meta.content}}" />
...
Answer the question
In order to leave comments, you need to log in
You hang a directive on each meta tag, in the link function include $watch (or $on) in the $watch (or $on) variable from $rootscope in the directive and add it to the content attribute when updating.
The variable in $rootscope changes when news is loaded (or broadcast to $broadcast), for example.
By the way,
<meta property="{{meta.property}}" content="{{meta.content}}" />
you don’t need to do this, it’s better to add default values to content and property, for example, a general description of the site. Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question