0

I have a app.js with defined routes and a menu with ng-href fields, like:

<li>
  <a ng-href="{{user.nick}}"><i class="icon-th-large"></i>My Content Flow</a>
</li>
<li>
  <a ng-href="{{user.nick}}/movie"><i class="icon-film"></i>My Videos</a>
</li>
<li>
  <a ng-href="{{user.nick}}/blog_post"><i class="icon-pencil"></i> My Blogs</a>
 </li>
<li>

Route Provider config:

$routeProvider
        .when('/:searchType?/:searchValue?', {
            templateUrl: 'partials/name/flow/',
            controller: 'FlowCtrl'
        })
.otherwise({
    redirectTo: '/'
});

$locationProvider.html5Mode(true);

:searchType is the user nick

:searchValue is gallery, movie or blog_post

Sometimes, when I click on the link, angular.js refresh the whole page, doing an application re-initialization. Can I avoid the whole refresh without using special directives and why sometimes works and sometimes doesn't?

If you want to see the demo go on filmannex with:

email: [email protected]

password: testing

Thanks

2
  • Please show us how your routes are configured with the $routeProvider at the module config method. Commented Jul 25, 2014 at 12:58
  • Did not see the behavior described with demo. Commented Jul 25, 2014 at 19:57

1 Answer 1

1

You should have a leading / before your ng-href values. I suspect they are interpreted as relative URLs so it is probably falling into the otherwise() bucket and redirecting to /

<a ng-href="/{{user.nick}}">user</a>
<a ng-href="/{{user.nick}}/movies">movies</a>
Sign up to request clarification or add additional context in comments.

Comments

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.