Last active
November 23, 2015 13:16
-
-
Save thicolares/c79caa1ef7e0e084fbf9 to your computer and use it in GitHub Desktop.
Usando a HTML5 History Api no Angulajs (testado na versão 1.4.7)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Options +FollowSymLinks | |
<ifModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteCond %{REQUEST_URI} !index | |
RewriteRule (.*) index.html [L] | |
</ifModule> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('minhaApp', []) | |
.config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) { | |
//... | |
// usando a HTML5 History API | |
// https://docs.angularjs.org/guide/$location | |
// nem todo navegador reconhece isso, mas a grande maioria: http://caniuse.com/#feat=history | |
$locationProvider.html5Mode(true); | |
//... | |
}]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta http-equiv="Content-Language" content="pt-br"> | |
<!--colocar a tag base--> | |
<base href="/"> | |
<!--...--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<a href="/a-route-name" title="A fancy title"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$location.path('/a-route-name'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment