0

I have a basic application runing localy using apache/WAMP etc. This setup is fine, and I've built quite a few apps using this and AngularJS.

Previous apps used ui-router for the route/state build. This app I'm building now is just using the normal ngRoute and ng-view.

Issue: Using $routeProvider I setup two routes.

app.js ( basic setup with angular-route added to scripts and "ngRoute" added to deps )

$locationProvider.html5Mode(true);

$routeProvider.when("/", {template: "<div>Home</div> <a href='/single'>Single</a> | <a href='/page/34'>Page 34</a>"});
$routProvider.when("/single", {template: "<div>single</div>"});
$routProvider.when("/page/:pageId", {template: "<div>page</div>"});
$routeProvider.otherwise("/");

.htaccess

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]

When I run this app to "/" everything is ok. Using the anchors the app will switch views with no issues

When I start the app at "/single" everything is fine

When I start the app at "/page/34" I get a module error stating that my module "Application" wasn't loaded...weird. only routes with named groups or longer than a straight page, e.g. /page/something don't work. doesn't matter what the route is.

I'm very perplexed.

Thanks for any clarification.

Is there something I'm missing? I can't figure out why this doesn't work.

Update
I fell prey to the bug. See this post: https://stackoverflow.com/a/17882453/2012550

1 Answer 1

0

Do you mean to have html5Mode(true);?

This expects your server to know that no matter what path is requested, the index file should be served back so that angular can handle the real routing on the front end. Remove that line and you will notice a #/ in your path

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

1 Comment

I don't want to remove html5 mode. I found my answer. Unfortunately I fell nprey to the <base href> bug. - stackoverflow.com/a/17882453/2012550

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.