Jeremy Kinser Jeremy Kinser - 1 year ago 167
AngularJS Question

ngMeta injection error, what am I doing wrong?

I am trying to utilize ngMeta in my app but I am getting an injection error.

Error: [$injector:modulerr] Failed to instantiate module ngMeta due to:
Error: [$injector:nomod] Module 'ngMeta' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.

Here is my app code:

var myApp = angular.module('myApp', ['ngRoute', 'ngMeta'])

.config(function ($routeProvider, $locationProvider, ngMetaProvider) {
//default route
.when('/', {
templateUrl: 'test-list.html',
controller: 'testController',
meta: {
title: 'test title',
description: 'test description'
.when('/productlist/another', {
templateUrl: 'another-list.html',
controller: 'anotherController',
meta: {
title: 'test title 2',
description: 'test description 2'

redirectTo: '/'


}).run(function ($rootScope, $route, ngMeta) {
//used for access to query string params
$rootScope.$route = $route;

Here is the html that utilizes the ngMeta values.

<html ng-app="myApp">
<meta charset="utf-8">
<meta name="fragment" content="!">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta property="og:title" content="{{ngMeta.title}}" />
<meta property="og:description" content="{{ngMeta.description}}" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="author" content="blah blah">
<base href="/" />
<title ng-bind="ngMeta.title"></title>

I have installed the npm module ng-meta and everything appears to be good on that front.

Can anyone help me figure out why I'm getting the dependency injection error? I've been trying different ways to get this to work based off of the Git examples and the ngMeta homepage examples but they both contain different ways of instantiating the module, neither of which have worked for me.

Answer Source

This sounds like you do not have ngMeta loaded. Check the URL you provided to load the ngMeta file.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download