javascript - How do I implement `$locationProvider.html5Mode(true); -


What I do not understand is $ locationProvider.html5Mode (true); Delete your hash URL? Although this is just fixing the home page for me when you refresh the page it is not that what should redirectTo: handle?

  var rustyApp = angular.module ('rustyApp', ['ngRoute', 'viewController', 'mm .foundation', 'angular flexslider', 'ui.router'], function $ routeProvider, $ locationProvider) {$ routeProvider.when ('/', {templateUrl: '/partials/home.html', Controller: 'Home Controller'}); // When you enter / Also provides $ route provider as well as / home /. When ('/ work', {templateUrl: '/partials/work.html', controller: 'work controller'}); $ routeProvider.when ( '/ Contact', {templateUrl: '/partials/contact.html', Controller: 'ContactController'}); $ routeProvider.otherwise ($ redirectTo: '/'}); $ locationProvider.html5Mode (true) .hashPrefix (' ! ');});   

And this is my html:

It's in the head:

     

This shipping is ...

  & lt; Section class = "top-bar-section uk-navbar-flip" & gt; & Lt; ul class = "uk-navbar-nav" & gt; & Lt; Li my-active-link = "/" & gt; & Lt; A href = "/" & gt; & Lt; i class = "uk-icon-home uk-icon-medium" & gt; & Lt; / I & gt; Home & lt; / A & gt; & Lt; / li & gt; & Lt; li my-active-link = "/ # work" & gt; & Lt; A href = "/ # work" & gt; & Lt; i class = "uk-icon-photo uk-icon-medium" & gt; & Lt; / I & gt; Work & lt; / A & gt; & Lt; / li & gt; & Lt; li my-active-link = "/ # contact" & gt; & Lt; A href = "/ # contact" & gt; & Lt; i class = "uk-icon-envelope-o uk-icon-medium" & gt; & Lt; / I & gt; Contact & lt; / A & gt; & Lt; / Ul & gt; & Lt; / Section & gt;   

UPDATE

I changed it to my app.js file.

  $ locationProvider.html5Mode (correct) .hashPrefix ('!'); // it has been changed from   

to

  $ locationProvider.html5Mode (true);   

and it was added to a .htaccess file.

  & lt; ifModule mod_rewrite.c & gt; RewriteCond% {REQUEST_FILENAME} on RewriteEngine -s [or] RewriteCond% {REQUEST_FILENAME} -l [OR] RewriteCond% {REQUEST_FILENAME} -d RewriteRule ^ * $ -. (. *) [NC, L] RewriteRule ^ /index.html [NC, L] & lt; / IfModule & gt;   

However, this was to work when I was running the server via Apache. I think my problem was a static server, which was not configured to handle the request of the balloon spawn. I'm sure there are some add-ons for GullPan-Open etc. ...

This is because the webserver first handles the request, so if you do not have URL RERT in any framework, then it will only see the folder in your webpage with the name in its 'root'.

If you are using a node Express webserver, you can write it like this:

  app.all ('/ *', function ( Req, res) {res.sendfile (__DERNAM + '/ INDEX html'); // or whatever is your public folder}};   

For you Apache server, you must have .htaccess You can use something like this:

  & lt; ifmodule mod_rewrite.c & gt; RewriteBase / RewriteCond% {REQUEST_FILENAME} at RewriteEngine! -f RewriteCond% {REQUEST_FILENAME}! -d RewriteRule ^ (. *) /index.php/#/$1 // Hash and / or other prefix you want to be with Bella To use & lt; / IfModule & gt;    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -