Dynamic Metadata In AngularJS ngMeta
Welcome to the In infinityknow.com website! You will Step By Step learn web programming, easy and very fun. This website allmost provides you with a complete web programming tutorial presented in an easy-to-follow manner. Each web programming tutorial has all the practical examples with web programming script and screenshots available.For Dynamic Metadata In AngularJS – ngMeta Example
angularjs – Angular Dynamic meta tags in head
AngularJS, the very increasingly popular js framework and JavaScript UI framework, caal to the falls victim to each call this same fate.
[php]
AngularJS App
AngularJS King
This AngularJS web-application is truly All easy to incredible.
[/php]
ngMeta | Dynamic meta tags for your Angular SPA
Angularjs is a one type of the structure and reliance and very binding on JavaScript, all the url crawlers are left to read each call to templates, not data
[php]
{{ app.name }}
{{ app.username }}
{{ app.description }}
[/php]
ngMeta – AngularJS Modules, Plugins and Directives Syntax
the desired all the meta tags and some description add the directive we just created as an attribute below examples.
[php]
[/php]
Dynamic metadata in web pages using AngularJS
In this examples add to dynamically add ngMeta title tag and ngMeta description tag and ngmeta tags add.
[php]
…………..
…………..
///some meta add here
[/php]
app.js ($routeProvider )
[php]
$routeProvider
.when(‘/’, {
templateUrl: ‘views/contacthome.html’,
controller: ‘HomepageCtrl’,
dynemicmetadata: {
title: ‘Happy 2 help You’,
description: ‘infinityknow Solution data’ }
})
.when(‘/productlist’, {
templateUrl: ‘views/productlist.html’,
controller: ‘productlistCtrl’,
dynemicmetadata: {
title: ‘Happy 2 help You | productlist’,
description: ‘An very impressive to the productlist pages!’ }
})
[/php]
[php]
var infinityknow = this;
// Set custom and each options or use to all the provided fallback in angularjs (default) options
infinityknow.loadMetadata = function(dynemicmetadata) {
infinityknow.title = document.title = dynemicmetadata.title || ‘Happy 2 help You’;
infinityknow.description = dynemicmetadata.description || ‘infinityknow Solution data’;
};
// Route change events handler, sets all the route’s config defined metadata
$rootScope.$on(‘$routeChangeSuccess’, function (event, newRoute) {
infinityknow.loadMetadata(newRoute.dynemicmetadata);
});
[/php]
Dynamic Title and Description with AngularJS
[php]
return {
restrict: ‘A’,
scope: {
metaproperty: ‘@’
},
link: function postLink(scope, element, attrs) {
scope.default = element.attr(‘content’);
scope.metadata = metadataService;
// Watch for metadata changes and set content
scope.$watch(‘metadata’, function (newVal, oldVal) {
setContent(newVal);
}, true);
// Set the content attribute with new metadataService value or back to the default
function setContent(metadata) {
var content = metadata[scope.metaproperty] || scope.default;
element.attr(‘content’, content);
}
setContent(scope.metadata);
}
};
[/php]
Dynamically set metadata
[php]
metadataService.loadMetadata({
title: ‘Happy 2 help You | ‘ + article.title,
description: article.description
});
[/php]
index.html(Angular app with dynamic meta data)
[php]
[/php]
Dynamically Added Meta Data Indexed By Google Crawlers
[php]
nar infinityknow = this;
// Set custom and defult options or use to the provided fallback (default) options
infinityknow.loadMetadata = function(dynemicmetadata) {
infinityknow.title = document.title = dynemicmetadata.title || ‘Happy 2 help You’;
infinityknow.description = dynemicmetadata.description || ‘infinityknow Solution data’;
infinityknow.url = dynemicmetadata.url || $location.absUrl();
infinityknow.image = dynemicmetadata.image || ‘infinityknowhelping.com/companylogo.jpg’;
infinityknow.ogpType = dynemicmetadata.ogpType || ‘website’;
infinityknow.twitterCard = dynemicmetadata.twitterCard || ‘summary_infinityknow_image’;
infinityknow.twitterSite = dynemicmetadata.twitterSite || ‘@infinityknowhelping’;
};
// This Route change all the each handler event, sets the route’s config data defined metadata and title
$rootScope.$on(‘$routeChangeSuccess’, function (event, newRoute) {
infinityknow.loadMetadata(newRoute.dynemicmetadata);
});
[/php]
ngMeta | Dynamic meta tags for your Angular SPA | Dynamically include meta data in angularjs | ngMeta – AngularJS Modules, Plugins and Directives | Dynamically Added Meta Data Indexed By Google Crawlers