0

I have a homepage link that loads /register html page. But when I change css on the /register page and want to see it I have to go back to my localhost and then click the link again so the page loads again with new css. This is painfully time-consuming, is there a way to link /register with the page/route? Or at least remove /register from URL (so that localhost is only url for the whole app) so when the user refreshes the homepage welcomes him?

Homepage link:

<a href="#/register" class="button-play-g">REGISTER</a>

View gets loaded like this

app.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {
$routeProvider
    .when("/register", {
        templateUrl: "/register",
        controller: "registerController"
    })
    .otherwise("/");

    $locationProvider.html5Mode(true);
}]);
3
  • See if this helps: stackoverflow.com/questions/14718826/… Commented Oct 9, 2014 at 20:14
  • @tjg184 Thanks, but thats not really the issue. All I want is not to have to go to localhost and click register link every time I change css on localhost/register page. Commented Oct 9, 2014 at 20:28
  • Maybe you should add a new route: .when("/", { templateUrl: "/register", controller: "registerController" }) Commented Oct 9, 2014 at 22:38

2 Answers 2

0

This is an angular mechanic and is explained more in a recent question that I answered AngularJS + UI-Router - Manually Type URLs in HTML5 Mode without HashBang

Easy work around: use localhost/#/register instead to get to the page.

Since you are using

$location.html5mode(true);

This issue is directly related to how the files are being served to the browser. Your angular app itself only has one access point and that is your index.html page. When you type into your browser localhost/register, it is looking for the register directory, not the actual angular route. Since you've enabled html5 mode, it removed the hash bangs, which looks nice, but that requires additional configuration to be able to access the views individually without them.

Additional: If you want to remove the route URLs altogether, you will need to use stateProvider instead of routeProvider

Related article regarding stateProvider: Angular ui-router: Can you change state without changing URL?

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

Comments

0

Set in you html

<head>
  <base href="/yor base url">
</head>

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.