0

I'm trying to access a nested view with the direct url, without navigating through links but it's not working.

My config is:

myApp.config(function ($stateProvider, $locationProvider) {
    $stateProvider
        .state('st1', {
            url: '/st1',
            templateUrl: 'st1.html',
        })
        .state('st1.st2', {
            url: '/st2',
            templateUrl: 'st2.html',
        })
    ;
    $locationProvider.html5Mode(true);
});

st1.html:

<h1>ST1</h1>

<div ui-view></div>

<a ui-sref="st1.st2">ST2</a>

st2.html:

<h2>ST2</h2>

<a ui-sref="st1">ST1</a>

I go directly to /st1, typing it not clicking a link, st1 html shows up.

When I click the link in st1, the location path changes to /st1/st2 and st2's content shows up, that is what I want, but when I refresh on /st1/st2 the page is empty.

What do I miss?

7
  • 1
    That would be almost for sure your server configuration. Carefully check the FAQ github.com/angular-ui/ui-router/wiki/… Commented Dec 14, 2014 at 12:12
  • The index.html is loading but the views' aren't. Commented Dec 14, 2014 at 12:37
  • It's working with hashbang so yea my server conf must be the problem, but it seems to be good: root 'application#index' get '*path' => 'application#index' Commented Dec 14, 2014 at 13:47
  • 1
    This issue is for sure about the server setting. Check carefully the FAQ I gave you. If server is set properly, all will start to work. Here is working example Commented Dec 14, 2014 at 16:10
  • Gosh.. it was my fault. I always forget not to learn new things before the 3rd coffee... thanks for the help, it works now. Commented Dec 14, 2014 at 16:47

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.