I am planning to change meta Title,Meta keywords and Meta description dynamically using AngularJS 1.x to reflect in Facebook,Twitter,Google Plus and LinkedIn.
Is there any way to change dynamically? I am using REST Api calls.
Thanks,
-Venkat
I am planning to change meta Title,Meta keywords and Meta description dynamically using AngularJS 1.x to reflect in Facebook,Twitter,Google Plus and LinkedIn.
Is there any way to change dynamically? I am using REST Api calls.
Thanks,
-Venkat
4
Answers
Use Angular-update-meta , it will help you to update meta tags dynamically.
https://github.com/jvandemo/angular-update-meta
You can use
ng-bind
to dynamically create the content of any tag.For example:
And then in your controller:
Google now renders javascript so the dynamic page title, and meta tags, will be indexed correctly.
I also ran into this problem so I’ve created a library just for this. You can view it over here.
You can use it in two ways:
For each state you’ve defined using ui-router you can attach the following custom data:
simpleSeoTitle
,simpleSeoDescription
,simpleSeoKeywords
. These 3, whenever the state is active, will change the page’s title, description, or keywords.It also exposes a service called
simpleSeoService
. This service has 3 properties,title,
description, and
keywords`. These 3 are defined as getter and setter. These are useful when you have dynamic properties you want to attach.I would recommend you to use this library which is suggested by Tristan also. It works perfectly fine. and compatible with dynamic expressions also.
For updating meta-tags you can simply use the following markup in your view(s):
You can simply install it using this command:
Hope it will help someone.