Coder Social home page Coder Social logo

vinaygopinath / ngmeta Goto Github PK

View Code? Open in Web Editor NEW
153.0 7.0 42.0 350 KB

Dynamic meta tags in your AngularJS single page application

Home Page: http://vinaygopinath.github.io/ngMeta

License: MIT License

JavaScript 100.00%
angularjs meta-tags seo ui-router crawler opengraph

ngmeta's Introduction

ngMeta

Dynamic meta tags in your AngularJS single page application

npm version Build Status Join the chat at https://gitter.im/ngMeta/Lobby

This is an Angular 1.x module. Angular2 module is available as ng2-meta

Demo

vinaygopinath.github.io/ngMeta

Install

via NPM:

npm install ng-meta --save

via Bower:

bower install ngMeta --save

via CDN:

https://cdnjs.cloudflare.com/ajax/libs/ng-meta/1.0.3/ngMeta.min.js

or download the file from dist.

Getting started

  1. Add ngMeta as a dependency of your module. ngMeta supports ui-router and ngRoute.

    angular.module('YourApp',['ngMeta']);
  2. Add meta objects to your routes (ngRoute) or states (ui-router) and specify the meta tags appropriate to each view. Other than title and titleSuffix, which are reserved properties that affect the title of the page, the tag properties can be named as per your choice.

    .config(function ($routeProvider, ngMetaProvider) {
    
      $routeProvider
      .when('/home', {
        templateUrl: 'home-template.html',
        data: {
          meta: {
            'title': 'Home page',
            'description': 'This is the description shown in Google search results'
          }
        }
      })
      .when('/login', {
        templateUrl: 'login-template.html',
        data: {
          meta: {
            'title': 'Login page',
            'titleSuffix': ' | Login to YourSiteName',
            'description': 'Login to the site'
          }
        }
      });
      ...
    });
  3. [Optional] Set the default values of meta tags during Angular's configuration phase. If the meta object of a route does not contain a specific tag, the default value is used instead.

    //Add a suffix to all page titles
    ngMetaProvider.useTitleSuffix(true);
    
    // On /home, the title would change to
    // 'Home Page | Best Website on the Internet!'
    ngMetaProvider.setDefaultTitleSuffix(' | Best Website on the Internet!');
    
    //Set defaults for arbitrary tags
    // Default author name
    ngMetaProvider.setDefaultTag('author', 'John Smith');
  4. Let ngMeta initialize by calling the init() function in the app.js run block

    angular.module('YourApp', ['ngRoute', 'ngMeta'])
    .config(function($routeProvider, ngMetaProvider) {
      ....
    })
    .run(['ngMeta', function(ngMeta) {
      ngMeta.init();
    }]);
  5. Set the meta tags in your HTML file

    <title ng-bind="ngMeta.title"></title>
    
    <!-- Arbitrary tags -->
    <meta property="og:type" content="{{ngMeta['og:type']}}" />
    <meta property="og:locale" content="{{ngMeta['og:locale']}}" />
    <meta name="author" content="{{ngMeta['author']}}" />
    <!-- OR <meta name="author" content="{{ngMeta.author}}" /> -->
    <meta name="description" content="{{ngMeta.description}}" />

Defaults

Change app-wide behaviour and set default values to tags using these methods of ngMetaProvider. These defaults can be overridden by defining equivalent properties in the route/state meta object

angular.module('YourApp', [....,'ngMeta'])
.config(function(ngMetaProvider) {

	ngMetaProvider.useTitleSuffix(true);
    ngMetaProvider.setDefaultTitle('Fallback Title');
    ngMetaProvider.setDefaultTitleSuffix(' | YourSite');
    ngMetaProvider.setDefaultTag('author', 'John Smith');
});
Method Default Example
useTitleSuffix(boolean)
Toggles the use of a title suffix. When enabled, the title suffix of the route (if available) or the default title suffix is appended to the title of all pages.
false ngMetaProvider.useTitleSuffix(true);
setDefaultTitle(String)
Sets the default title for all routes. This serves as a fallback for routes that don't have a title property. Use this to customize titles for a few specific routes, letting other routes use the default title.
undefined ngMetaProvider.setDefaultTitle('Spotify');
ngMetaProvider.setDefaultTitle('Generic Title');
setDefaultTitleSuffix(String)
Sets the default title suffix for all routes. This serves as a fallback for routes that don't have a titleSuffix property. The default title suffix is relevant only when useTitleSuffix is set to true.
undefined ngMetaProvider.setDefaultTitleSuffix(' - Site Name');
ngMetaProvider.setDefaultTitleSuffix(' - YourSite');
setDefaultTag(String, String)
Sets the default value of any arbitrary tag. This serves as a fallback for routes that don't have a particular tag.
N/A ngMetaProvider.setDefaultTag('author', 'John Smith');
ngMetaProvider.setDefaultTag('ogImgUrl', 'http://example.com/img.png');

Dynamic meta tags

To change meta tags dynamically (when an item in a list is clicked, for example), inject the ngMeta service into your controller and use one of the following methods:

angular.module('YourApp')
.controller(function(ngMeta) {
  //These examples assume useTitleSuffix is enabled,
  //and default titleSuffix is set to 'Playlist'

  //Custom title and titleSuffix
  ngMeta.setTitle('Eluvium', ' | Spotify'); //Title = Eluvium | Spotify
  //default titleSuffix
  ngMeta.setTitle('Eluvium'); //Title = Eluvium | Playlist
  //Clear the default titleSuffix
  ngMeta.setTitle('Eluvium',''); //Title = Eluvium

  ngMeta.setTag('author', 'Matthew Cooper');
  ngMeta.setTag('image', 'http://placeholder.com/abc.jpg');

  ngMeta.setDefaultTag('author', 'Default author');
  //Set default tags (non-default tags, like author and image above, are NOT cleared)
  ngMeta.resetMeta();
});

Note: Please use setTitle to modify the title and/or titleSuffix and setTag for all other tags.

Method Description Example
setTitle(String title, String titleSuffix) Sets the current title based on the given params. When useTitleSuffix is enabled and titleSuffix is not provided, it uses the default titleSuffix. ngMeta.setTitle('Title', ' - TitleSuffix')

ngMeta.setTitle('Title with default titleSuffix')

ngMeta.setTitle('Title with no titleSuffix','')
setTag(String tagName, String value) Sets the value of an arbitrary tag, using the default value of the tag when the second param is missing. The value is accessible as {{ngMeta.tagName}} from HTML. Calling setTag with title or titleSuffix as tagName results in an error. Title must be modified using setTitle instead. ngMeta.setTag('author', 'John Smith')

ngMeta.setTag('ogImage', 'http://url.com/image.png')
setDefaultTag(String tagName, String value) Sets the default value of an arbitrary tag, overwriting previously set default values, but not the value set dynamically (using setTitle/setTag) or by the route/state. title and titleSuffix are accepted values. ngMeta.setDefaultTag('image', 'http://default-image-url.com');

ngMeta.setDefaultTag('title','Default title');
resetMeta(void) Applies the default meta tags. This is relevant when using ui-router and disableUpdate: true (Refer this comment). Custom tags set dynamically (using setTag or setTitle) are not cleared. ngMeta.resetMeta();

Debugging

  • ng-inspector Chrome extension shows the tags set by ngMeta when a state/route is open ng-inspector running on an Angular SPA with ngMeta

  • Facebook's Open Graph Object Debugger shows detailed information about your site's meta tags as well as a preview of the snippet shown when your site is shared. Note that you need to use server-side rendering or prerendering in combination with ngMeta to see your meta tags in the the debugger

Advanced

Data inheritance in ui-router

If you wish to take advantage of nested views and data inheritence, then you should specify your meta config underneath the data property like this:

$stateProvider
  .state('services', {
    abstract: true,
    url: '/services',
    templateUrl: '/services/base.html',
    controller: 'servicesCtrl',
    data: {
      'meta': {
        'og:image': 'http://www.yourdomain.com/img/facebookimage.jpg',
        'author': 'PawSquad'
      }
    }
  })
  .state('services.vaccinations', {
    url: '/vaccinations',
    templateUrl: '/services/vaccinations.html',
    controller: '',
    data: {
      'meta': {
        'title': 'Pet Vaccinations - All You Need To Know | PawSquad',
        'og:title': 'All You Need To Know About Pet Vaccinations',
        'og:description': 'Useful information about Routine Vaccines and Boosters for dogs and cats,   including start vaccines for puppies and kittens.',
      }
    }
  })

Furthermore, you should use the helper function to decorate $stateProvider's data function like this

.config(['ngMetaProvider', function (ngMetaProvider) {
  $stateProvider.decorator('data', ngMetaProvider.mergeNestedStateData);
}])

In this way the metadata for the /services/vaccinations URL would be

  'meta': {
    'og:image': 'http://www.yourdomain.com/img/facebookimage.jpg',
    'author': 'PawSquad',
    'title': 'Pet Vaccinations - All You Need To Know | PawSquad',
    'og:title': 'All You Need To Know About Pet Vaccinations',
    'og:description': 'Useful information about Routine Vaccines and Boosters for dogs and cats, including start vaccines for puppies and kittens.'
  }

Using custom data resolved by ui-router

If you want to dynamically set your tags using ui-router's resolve, this is possible as well:

resolve: {
  data: function(..., ngMeta) {
    //Ex: Load data from HTTP endpoint
    ....
    ngMeta.setTitle();
    ngMeta.setTag('description', '....');
    ngMeta.setTag('image', '....');
  }
},
meta: {
  disableUpdate: true
}

The property disableUpdate: true is required because ui-router will execute the resolve function before the $stateChangeSuccess event is fired. Setting disableUpdate: true will prevent your tags from getting reset by the $stateChangeSuccess event listener.

Support for other crawlers

While Google is capable of rendering Angular sites, other search engines (?) and crawler bots used by social media platforms do not execute Javascript. This affects the site snippets generated by sites like Facebook and Twitter. They may show a snippet like this one:

Facebook site snippet

You can use prerendering services to avoid this issue altogether, or update the server config to generate and serve a simplified page with just the open graph meta data needed for the bots to create snippets. Michael Bromley's article, Enable Rich Sharing In Your AngularJS App has more information on how to do that.

TL;DR: ngMeta helps the Google crawler render your Angular site and read the meta tags. For other sites like Facebook/Twitter that can't render Javascript, you need to use pre-renderers or server redirects.

Websites using ngMeta

  • acloud.guru - AWS certification online learning platform

To list your website here, please make a PR (or edit README.md on GitHub) and add your URL in this section of README.md in this format

"Site URL - Short description"

Further reading

MIT Licence

Vinay Gopinath

ngmeta's People

Contributors

jacobcsmith avatar martyzz1 avatar mcgilly17 avatar thewrongalice avatar vinaygopinath avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

ngmeta's Issues

Not working with Webpack

I tried using this with Webpack (using require and import) however i couldn't get it to work.

By making the following change:

return angular.module('ngMeta', [])

It worked in webpack.

ngMeta does not change title tag when placed in head

Hi,

I've just tried to make ngMeta work.
I have been able to change the title tag only if it was placed at the end of the body.

How do i make it work with title tag inside the head ?
ngMeta is sourced inside the body.

No substitution with grunt (angular 1.5.8)

Hi,
Have followed your steps 1-5 carefully.

Both grunt serve and build always yield the following:
<title ng-bind="ngMeta.title"></title> <meta name="description" content="{{ngMeta.description}}">

after correcting configuring and adding the preferred meta on the page in question:

    data: {
      meta: {
        'title': 'Home page',
        'description': 'This is the description'
      }
    }

In the controller have also tried the following with no effect:

ngMeta.setTitle('Demo page');
ngMeta.setDescription('This is the description of the demo page');

No errors in the console.

Hope you can help

Google Indexing (Continuation of old ticket)

I'm still having issues with Google Indexing on this site (www.klaasrealty.net). I wasn't able to resolve the issue. We had a ticket open that was closed several months ago. However, the issue never really resolved. I tried to concat and uglify my JS assets thinking that would help, but still no dice. Would love to put this issue to rest, but I'm at a loss for ideas.

indexing

README.md

Please update documentation that disableUpdate: true (for ui-router) needs to be in the "data" object to work properly. Now its directly in the state's root

Broken ngMeta demo

schermata 2016-09-14 alle 10 33 14

Hi all,
i'm trying to test your demo site on facebook debugger page and doesn't work. It's normal?

I've tried to use yours module for my app but it gives me the same results. Any suggestion?
thanks

Google won't use the meta information

Hello.

I'm not sure if this is still maintained or supported. But I'll try asking.
While not technically an issue with the service itself, I'm hoping to get some hints or some guidance.

I'm experimenting with opening up my angular application to be indexed by Google and am trying out systems that will correctly set meta info for each page, however, in the Google search result I'm seeing my test pages previewing the index.html file I use to start the angular app, and not the actual info in the meta.

Is there perhaps a step I'm missing, or some special meta tag to set?

Thank you in advance

On project build ngMeta does't work

Hi,
I'm using grunt to build my project
So on grunt serve, ngMeta works fine
on Grunt Build which creates a dist folder.. there ngMeta doesnt work
im trying to set the page title though

Option to leave out suffix when title is default

I would like to have a title suffix that always applies automatically ngMetaProvider.useTitleSuffix(true); but not when the default title is being used.

so to put this into an example, if I use this configuration

ngMetaProvider.setDefaultTitle('Site name');
ngMetaProvider.useTitleSuffix(true);
ngMetaProvider.setDefaultTitleSuffix(' | Site name');

then

meta: {
  title: 'Page name' // Gives me the title "Page name | Site name"
}

and

meta: {} // Gives me the title "Site name"

Support inheritance for child states for ui-router

Hello, very nice service!
What do you think about support for inheritance for child states in ui-router?
At the moment it doesn't work for 'title' for example, but does for 'description'. I think this is why you are resetting the current state of ngMeta object in readRouteMeta() function.
It would be really nice enhancement!

Allow titleSuffix to be set / removed programmatically

There are certain pages where I don't want a titleSuffix set, but on the majority I do.

I can't seem to turn off the title suffix programatically. It'd be good if I could do it in 2 ways:

In the route:

meta: {
    useTitleSuffix: false
}

Programatically:

ngMeta.useTitleSuffix(false);

And have that only apply until the next $stateChange

Btw, nice work -- a really useful library :-)

no description

html:
`

<title ng-bind="ngMeta.title"></title> ...` Localy it work perfect, but when I use it on server, I can't see "description". Title work, but description not(( Server use https and there are no console mistakes. http://joxi.ru/Vrw6L7fKdwe3AX I try to use ng-attr-content, but it didn't help.

Help Please

Hi Vinay,
Thanks for writing what seems to be some awesome code!
I am having some problems getting it going in my Grunt project and would appreciate your help please.
I added your "ngMeta" component via bower to my project build and updated my "bower.json" file like this:

    {
      "name": "yeoman-angular-test",
      "version": "0.0.0",
      "dependencies": {
        "angular": "^1.4.7",
        "angular-animate": "^1.3.0",
        "angular-aria": "^1.3.0",
        "angular-cookies": "^1.3.0",
        "angular-messages": "^1.3.0",
        "angular-resource": "^1.3.0",
        "angular-route": "^1.3.0",
        "angular-sanitize": "^1.3.0",
        "angular-touch": "^1.3.0",
        "ngMeta": "^0.2.1"
      },
      "devDependencies": {
        "angular-mocks": "^1.3.0"
      },
      "appPath": "app",
      "moduleName": "yeomanAngularTestApp"
    }

Here's the my HTML5 meta tags:

    <title>{{ metaTags.title }}</title>
    <meta name="description" content="{{ metaTags.description }}">

Here's my JS Body links:

        <!-- build:js(.) scripts/vendor.js -->
        <!-- bower:js -->
        <script src="bower_components/angular/angular.js"></script>
        <script src="bower_components/angular-animate/angular-animate.js"></script>
        <script src="bower_components/angular-aria/angular-aria.js"></script>
        <script src="bower_components/angular-cookies/angular-cookies.js"></script>
        <script src="bower_components/angular-messages/angular-messages.js"></script>
        <script src="bower_components/angular-resource/angular-resource.js"></script>
        <script src="bower_components/angular-route/angular-route.js"></script>
        <script src="bower_components/angular-sanitize/angular-sanitize.js"></script>
        <script src="bower_components/angular-touch/angular-touch.js"></script>
        <script src="bower_components/ngMeta/src/ngMeta.js"></script>
        <!-- endbower -->
        <!-- endbuild -->

        <!-- build:js({.tmp,app}) scripts/scripts.js -->
        <script src="scripts/app.js"></script>
        <script src="scripts/controllers/main.js"></script>
        <script src="scripts/controllers/about.js"></script>
        <script src="scripts/controllers/contact.js"></script>
        <!-- endbuild -->

Here's my AngularJS app:

    angular
      .module('app', [
        'ngAnimate',
        'ngAria',
        'ngCookies',
        'ngMessages',
        'ngResource',
        'ngRoute',
        'ngSanitize',
        'ngTouch',
        'ngMeta'
      ])
      .config(function ($routeProvider, ngMetaProvider) {
        $routeProvider
          .when('/', {
            templateUrl: 'views/index.dot.html',
            controller: 'MainCtrl',
            meta: {
              title: 'Home title',
               description: 'Home description'
            }
          })
          .when('/about', {
            templateUrl: 'views/about.html',
            controller: 'AboutCtrl',
            meta: {
              title: 'about title',
              description: 'about description'
            }
          })
          .when('/contact', {
            templateUrl: 'views/contact.html',
            controller: 'ContactCtrl',
            meta: {
              title: 'contact title',
              description: 'contact description'
            }
          })
          .otherwise({
            redirectTo: '/'
          });
          ngMetaProvider.setName('metaTags');
      });

Here's my controller file "main.js":

    'use strict';
    angular.module('app')
    .controller('MainCtrl', function ($scope, $route) {
        $scope.awesomeThings = [
            'HTML5 Boilerplate',
            'AngularJS',
            'Karma'
        ];
        $scope.$route = $route;
    });

Here's my controller file "about.js":

    'use strict';
    angular.module('app')
        .controller('AboutCtrl', function ($scope, $route) {
            $scope.awesomeThings = [
                'HTML5 Boilerplate',
                'AngularJS',
                'Karma'
            ];
            $scope.$route = $route;
        });

Here's my controller file "contact.js":

    'use strict';
    angular.module('app')
        .controller('ContactCtrl', function ($scope, $route) {
            $scope.awesomeThings = [
                'HTML5 Boilerplate',
                'AngularJS',
                'Karma'
            ];
            $scope.$route = $route;
        });

Please let me know if you need any further information or explaination.
Kind regards,
Derek

ngMeta is not initializing any more

ngMeta was working well.
Now it is not initializing any more :
all my page where ngMeta used to use defaultTags are not working any more.

I recently updated to angular 1.6.

Thanks for you help

Google indexing issue with ngMeta

I'm using ngMeta and when I inspect the my head tag using the Chrome console, I see ngMeta is in fact changing my meta values. So, at first glance, I thought this solution was working. However, Google is not indexing those values. Instead it is indexing the description {{ngMeta.description}} when it crawls my page. Any idea how to fix this?

Website: www.klaasrealty.net | Google Search: klaas realty

untitled

Google search not using title, description tags

I am using Angular JS 1.58 and I am trying to change Title, Description, Keywords, dynamically using ngMeta. I successfully implemented it, no errors, and I verified that title and meta description and keywords are changing correctly, using the Chrome inspector elements.

From experimenting last several weeks, I found the following:

When I use the ngMeta to change the title and description, google search results do not pick them up and uses the page content to display a title and description. So, the content is rendered correctly, not the tags.

When I use the ngMeta to change the title only, but hard code the meta description and keywords, Google search displays the correct title and description. I verified this behavior several times, going back and forth and using the google webmaster fetch and request to index feature.

Anyone can help? Would rewriting my web site with Angular 2 resolve this issue, or since ngMeta still would need to be used, it would have the same issue?

Minification Breaking Application

Since adding ngMeta it runs as you would expect it to but when minified it breaks throwing the following error.

Uncaught Error: [$injector:unpr] Unknown provider: eProvider <- e

I'm struggling to locate the cause. Some help would be appreciated.

Thanks!

when i pen view source i don't see my title or description


<html ng-app="app">
  <head>
   <base href="/">
   <meta charset="utf-8">
   <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <meta name="fragment" content="!">
 <title>{{ngMeta.title}}</title>
    
   <!-- Arbitrary tags -->
  <meta property="og:type" content="{{ngMeta['og:type']}}" />
   <meta property="og:locale" content="{{ngMeta['og:locale']}}" />
  <meta name="author" content="{{ngMeta['author']}}" />
   <!-- OR <meta name="author" content="{{ngMeta.author}}" /> -->
   <meta name="description" content="{{ngMeta.description}}" />
  <script>

this is what i get on my view source and for sure it is not working on google.

but when i inspect the page i see everything showing. don't understand what is the issue exactly.

Not being able to display dynamic content

Hello,
First of all, I'm pretty lame at JS and Angular, so I'm probably doing some rookie mistake. (Yep, not a programmer)
So, I'm struggling to put dynamic content into the ngMeta.

In my module I have the followed code:

noticia

However, it will print like this:

noticias2

How can I make this dynamic?
I tried following the documentation, but there is something I'm not getting it right.

In my controller I tried putting this:
ngMeta.setTag('description', 'noticia.NoticiasConteudo)');

But I have no idea where to put the ngMeta.setTag, since it didnt work into the <meta name="description" content="{{ngMeta.description}}">

Since I got this bomb on my lap and I need to fix it, could anyone help a fellow designer that have no idea what he is doing?

Thanks!

ionic: title and meta tags are not updated

Hi, Thank you for the great Module! I'm trying to setTitle and metatags on my controller and ui-router.
I could see variable passed by using console but it doesn't update and show title as changed one. When I inspect the title, it says it's missing. (BTW I'm using Ioinc Framework and ng-inspector doesn't work properly so I'm using this chrome extention=> https://chrome.google.com/webstore/detail/seo-meta-in-1-click/bjogjfinolnhfhkbipphpdlldadpnmhc)

Title : Title is missing!
Description : {{ngMeta.description}}

Here is my code.
index.html

<title ng-bind="ngMeta.title"></title>
<!-- OR <title>{{ngMeta.title}}</title> -->    

<!-- Arbitrary tags -->
<meta property="og:type" content="{{ngMeta['og:type']}}" />
<meta property="og:locale" content="{{ngMeta['og:locale']}}" />
<meta name="author" content="{{ngMeta['author']}}" />
<!-- OR <meta name="author" content="{{ngMeta.author}}" /> -->
<meta name="description" content="{{ngMeta.description}}" />

app.js

        $stateProvider
.state('app.myPage', {
            url: "/myPosts",
            views: {
                'myPost': {
                    templateUrl: "templates/themes/news-feed/html/post-my.html",
                    controller: "myPostListCtrl"
                }
            },
    data: {
      'meta': {
        'title': 'My Post- All You Need To Know | PawSquad',
        'og:title': 'All You Need To Know About Pet Vaccinations',
        'og:image': 'http://www.yourdomain.com/img/facebookimage.jpg',
        'author': 'PawSquad'
      }
    }

ngMeta.js

        var setTitle = function(title, titleSuffix) {
          console.log("Settitle called: "+title,titleSuffix);
          if (!$rootScope.ngMeta) {
            throw new Error('Cannot call setTitle when ngMeta is undefined. Did you forget to call ngMeta.init() in the run block? \nRefer: https://github.com/vinaygopinath/ngMeta#getting-started');
          }

          $rootScope.ngMeta.title = angular.isDefined(title) ? title : (defaults.title || '');
          if (config.useTitleSuffix) {
            $rootScope.ngMeta.title += angular.isDefined(titleSuffix) ? titleSuffix : (defaults.titleSuffix || '');
          }
          console.log("$rootScope.ngMeta.title"+$rootScope.ngMeta.title);
          return this;
        };

on console It shows everything Fine

myAnotherController.js

  ngMeta.setTitle('Eluvium'); //Title = Eluvium | Playlist
  ngMeta.setTag('author', 'Matthew Cooper');
  ngMeta.setTag('image', 'http://placeholder.com/abc.jpg');
  ngMeta.setDefaultTag('author', 'Default author');

  console.log("$rootScope.ngMeta"+JSON.stringify($rootScope.ngMeta));

$rootScope.ngMeta{"title":"Eluvium | YourSite","og:image":"http://www.yourdomain.com/img/facebookimage.jpg","author":"Matthew Cooper","image":"http://placeholder.com/abc.jpg"}

TypeError: Cannot read property 'meta' of undefined

When you are in an Angular + AngularJS hybrid app, the current property from the ngRoute will be undefined when you are routing to an Angular route from an AngularJS route. This is a problem for this service, since it depends on current property always being defined. We need to add an undefined check.

Support changing defaults

Hi, thanks for the great service!

Would it be possible to add support for changing defaults? Basically, I am getting my default values from an API call, therefore it would be too late for me to set the defaults after the config is already run.

Thanks!

One of my website meta tags are not initializing

One of my website meta tags are not initializing..Could you please help ..

When am checking in browser it is showing title but when am copying the same in whatsapp or facebook,it is showing as {{meta.title}} and {{meta.description}}.

.config(function ($routeProvider, ngMetaProvider)
{
.when("/", {
templateUrl: 'templates/inside.php',
controller: 'insideCtrl',
meta: {
'title': 'Inside Page',
'og:title': 'Inside Page',
'description': 'Inside Page'
'og:description': 'Inside Page'
}
}
}
myApp.run(function (ngMeta)
{
ngMeta.init();
})

On Index Page, mentioned as below:

<title>{{ngMeta.title}}</title> <script src="https://cdnjs.cloudflare.com/ajax/libs/ng-meta/1.0.0/ngMeta.min.js" type="text/javascript"></script>

in Bower.json it is setting the bath to src instead of dist

Hi there..

the library was working fine till I think you made an update that causes two issues. the first one,, I couldn't get the file to be added to my index.html.. and when I checked . the folders are under dist,, while in bower.json is says the the main file is under "main": "src/ngMeta.js",... when I changed the src to dist it worked.

Second thing is that you are now reserving the title and title suffex to the function setTitle. why? that caused my whole website not setting titles since I am using setTag('title','..');... I hope that you can do a quick fix for it. thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.