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);
}]);
Dusan J.
  • 193
  • 4
  • 18
  • See if this helps: http://stackoverflow.com/questions/14718826/angularjs-disable-partial-caching-on-dev-machine – tjg184 Oct 09 '14 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. – Dusan J. Oct 09 '14 at 20:28
  • Maybe you should add a new route: .when("/", { templateUrl: "/register", controller: "registerController" }) – Aidin Oct 09 '14 at 22:38

2 Answers2

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?

Community
  • 1
  • 1
dannypaz
  • 1,244
  • 1
  • 12
  • 14
0

Set in you html

<head>
  <base href="/yor base url">
</head>
Harutyun Abgaryan
  • 1,943
  • 1
  • 9
  • 15