1

I am trying to get access to the current route since I added a title on it.

So the route looks something like

state('reports', {
    title: 'Reports',
    url: '/reports',
    templateUrl: 'modules/feeditems/views/reports.client.view.html'
}).

I want to get access to the title. so I can put it on my page Header. So in the Header controller I thought I could just get it off my

angular.module('core').controller('HeaderController', ['$rootScope', '$route', '$scope', 'Authentication', 'Menus',     
function($rootScope, $route, $scope, Authentication, Menus) {
        $scope.authentication = Authentication;         
        $scope.isCollapsed = false;
        $scope.menu = Menus.getMenu('topbar');
        $scope.$route = $route;
        console.log ('typeof($route) = ' + typeof($route));
        console.log ('typeof($route.current) = ' + typeof($route.current));

and I get the following error

Error: [$injector:unpr] Unknown provider: $routeProvider <- $route

so I add ngRoute

ApplicationConfiguration.registerModule('core', ['ngRoute']);

then I get the following error

Uncaught Error: [$injector:modulerr] Failed to instantiate module r2h due to: Error: [$injector:modulerr] Failed to instantiate module core due to: Error: [$injector:modulerr] Failed to instantiate module ngRoute due to: Error: [$injector:nomod] Module 'ngRoute' 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.

How am I supposed to include this properly? the meanjs way?

Pankaj Parkar
  • 134,766
  • 23
  • 234
  • 299
Leo
  • 1,495
  • 23
  • 41
  • 1
    Are you using `ui-router` or `ngRoute`? Your route definition shows that you're using `state`, which would be `ui-router`, but everything else looks like you're asking for help with `ngRoute` – Tom Apr 10 '15 at 18:53
  • @Tom ui-router. That is my first problem. I thought I was using ngRoute but it is actually ui-router. But I still can't seem to get title out. – Leo Apr 10 '15 at 20:04

2 Answers2

2

I think you are confused, MeanJS standard configuration uses Angular UI Router

For Angular UI Router

You need to angular-ui-router.js then include ui.router inside your app dependency

After that in configuration do register your state using $stateProvider

Syntax

app.config(function($stateProvider){

    $stateProvider.state('reports', {
        url: '/reports',
        templateUrl: 'modules/feeditems/views/reports.client.view.html'
    })

})

For adding title dynamically you could refer this SO Answer

Community
  • 1
  • 1
Pankaj Parkar
  • 134,766
  • 23
  • 234
  • 299
  • so it looks like I am using Angular UI Router. How do I then get the title out? – Leo Apr 10 '15 at 20:02
1

Kindly refer to https://stackoverflow.com/a/28252931/4380266 . This has the solution to your problem.

Check the sequence you loaded your angular files. The sequence must be :

angular.js 
angular-route.js 
finally your angular scripts
Community
  • 1
  • 1
K Rajesh Kumar
  • 267
  • 3
  • 8