I'm writing metadata service for my website and SEO optimisaion and it seems i cant get past the error. I'm not sure why. I have my html controller tag inserted in head tag
ng-controller="MetaDataCtrl"
. I'm beginer in Angular and I'm scraping from on line tutorials.
I found this code in:dynamic metadata in angular
Main.js
var app = angular.module('WebApp', [
'ngRoute'
]);
angular.module("WebApp").service("metadataService" ["$location", "$rootScope", function($location, $routescope) {
var self = this;
self.tags = {};
// Set custom options or use provided fallback (default) options
self.loadMetadata = function loadMetadata(metadata) {
metadata = metadata || {};
metadata.title = metadata.title || 'BNL Consulting';
metadata.description = metadata.description || 'We are BNL Consulting.';
document.title = metadata.title;
self.tags = metadata;
};
// Make sure data gets reloaded when navigation occurs
$rootScope.$on('$routeChangeSuccess', function (event, newroute, oldroute) {
self.loadMetadata(newroute.metadata);
});
}
]),
/**
* Configure the Routes
*/
app.config(['$routeProvider', '$locationProvider', function($routes, $location) {
$location.html5Mode(true).hashPrefix('!');
$routes
// Home
.when("/", {templateUrl: "partials/home.html",
controller: "PageCtrl",
metadata: {
title: 'This is my title',
description: 'This is Desc.' }
})
}]);
app.controller('PageCtrl', function (/* $scope, $location, $http */) {
});
.controller('MetadataCtrl', function ($scope, metadataService) {
$scope.meta = metadataService;
});