0

I've been trying all day to get the AngularUI Router working with 1.2.0-rc.3, but to no avail. I'm pretty sure it's a bug, as a lot of things have been changed in rc3, but maybe someone has found a workaround for it.

This is what I'm trying to do:

In my app.config()

var login = {
    url        : '/login',
    name       : 'login',
    templateUrl: 'views/login.html',
    controller : 'LoginCtrl'
};
var main = {
    url        : '/',
    name       : 'main',
    templateUrl: 'views/main.html',
    controller : 'MainCtrl'
};
var reportsOverview = {
    url        : '/reports',
    name       : 'main.reports',
    controller : 'ReportsCtrl',
    templateUrl: 'views/main.reports.html'
};

$stateProvider.state(login);
$stateProvider.state(main);
$stateProvider.state(reportsOverview);

When I go to /login, my template gets displayed as expected. When I go to / or /reports however, I see nothing. I've got a <div ui-view></div> in both my index.html and views/main.html file, so that's not the issue.

Anyone out there experiencing the same issue, or what am I doing wrong?

1 Answer 1

1

It's hard without being able to see the custom templates, but some things I noticed that you are going to /reports. Urls are additive, so, in your case because the main url is / and your reports url is /reports the actual url you would have to go to is //reports not /reports. Try making your reports url reports and then /reports should work.

I would try to use ui-sref directive to create links on your web page so that you can see what urls the routing is generating for each state and check that it is what you expect.

It would be really helpful if you could include a plunkr that demonstrates the problem you are having.

Sign up to request clarification or add additional context in comments.

1 Comment

That totally makes sense, wow. Thanks a lot, it worked like a charm!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.