Reputation: 703
I want reload my view from navigation bar and this show me the browser server... I have the html5Mode activated:
if(window.history && window.history.pushState) {
$locationProvider.html5Mode(true);
}
Exameple:
-I load http://localhost/myBase/
-when I click in link, I load the view and show this url in navigation bar http://localhost/myBase/page1
-then, I refresh the page and as I don't have a hashtag in the url, In navigator show the server folder...
could refresh page without hashtag and be in same page?
Upvotes: 1
Views: 819
Reputation: 186
There's a complex solution to your problem: if you can access to apache configuration, and apache has enabled de rewrite module, you can make a rule to rewrite the url in case of this not contains the hashtag.
Options +FollowSymLinks
RewriteEngine On
RewriteBase /yourBaseUrl
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^#]+)$ #/$1 [NE,R]
Putting the previous code in your .htaccess file or in your virtualhost configuration you can solve your problem. But be carefully modificating this, you can broke the entire web server.
Happy coding!
Upvotes: 2
Reputation: 961
For your purpose i often use two between these solutions,
1) I use angular-ui rather then ng-view, it uses states rather then address, and it handles the addresses in the navigation bar in a way that you could not consider the '#', in fact the ui-router module when 'receives' an address, knows the view that it has to use.
2)the second way it's a little bit less elegant, you could put a script in the main page like:
function foo('somewhere'){
window.onload=function(){
$location.path(somewhere)
}
}
I had use that solution once, because i already had a big application and i didn't want to substitute ng-view, but since that time i always use ui-router, in somewhere you put a global variable that refer to the actual page.
Upvotes: 0
Reputation: 222
I don't think it's possible because a refresh is a browser thing. It's beyond the scope of javascript. The browser will send out a request to the server and render the page again which will angular bootstrap again and your application will get an initial state.
Have a look at this: routing and clean path (no hashtag) not working in angularJS
Upvotes: 0