For some reason $state.current is always blank when I try to access it from 
a directive controller. Does the directive load before state evaluation? If 
so, is there a work around for this? I need to show the correct navigation 
based on the state in a SPA

For example in my view, I have: <navigation></navigation>

My directive:

angular.module('app')
        .directive('navigation', function($state){
            return {
                restrict: 'E',
                controller: function() {
                    alert($state.current.name);
                }
            }
         });

My routes:

angular.module('app')
        .config(function ($stateProvider, $urlRouterProvider, 
$locationProvider) {
            $urlRouterProvider.otherwise('/home');
            $stateProvider
                    .state('home', {
                        url: '/home',
                        views: {
                            "title": {
                                template: "<title>Home</title>"
                            },
                            "body": {
                                templateUrl: 
'app/components/home/homeView.html',
                            },
                            "navigation" : {
                                templateUrl: 
'app/shared/navigation/homeNavBarView.html'
                            }
                        }

                    })
        });

The way i have it set up is that i create the module separately, then i setup 
routing in a separate file, and the directive is also in a separate file. Then 
they are loaded in an index  file in order. Not sure if this has anything to do 
with it

What am I doing wrong?

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to