0

Say, I am browsing localhost/index.html#/view1, and I have a link pointing to localhost/index.html . When I click it, angular process it through its ng-route module and it falls into my redirect clause.

this is an extract from the route config:

$routeProvider
    .when( "/view1", route1 )
    .otherwise({redirectTo:'/view1'}); // localhost/index.html clicks fall here

I could use a ng-click and then redirect javascriptly with location.href, but this is not a desirable solution because I would lose the href link(SEO, bookmark, tabs).

tl;dr

How do I tell angularJs ng-route not to process urls without hash ?

EDIT: I do not user html5 mode and do not plan on using it.

1 Answer 1

3

If you are asking about angular routing service ignoring the url links. See documentation of $location

In cases like the following, links are not rewritten; instead, the browser will perform a full page reload to the original link.

Links that contain target element

Example: <a href="/ext/link?a=b" target="_self">link</a>

Absolute links that go to a different domain

Example: <a href="http://angularjs.org/">link</a>

Links starting with '/' that lead to a different base path when base is defined

Example: <a href="/not-my-base/link">link</a>
Sign up to request clarification or add additional context in comments.

1 Comment

this is exactly what I was looking for, thanks a lot! target="_self" did the trick

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.