query ui.router assigns a # before routes

0

I'm trying ui.router but I have a problem whenever the ui-sref comes before a #

<!DOCTYPE html>
<html ng-app="app">
<head>

    <title>Indice</title>
    <script src="/angular/angular.min.js"></script>
 <script src="/satellizer/satellizer.js"></script>

<script type="text/javascript" src="/angular-ui-router/release/angular-ui-router.js"></script>


<script type="text/javascript" src="/js/index2.js"></script>
</head>
<body>
<a ui-sref="register">Register</a>
<a ui-sref="auth">Auth</a>

<a ui-sref="me">Me</a>

</body>
</html>

index2.js

angular.module("app",["satellizer","ui.router"])
.config(function($stateProvider,$urlRouterProvider){
$stateProvider.state('register',{
    url:'/api/register',
});
$stateProvider.state('auth',{
    url:'/api/auth',
});
$stateProvider.state('me',{
    url:'/me',
});

});

example: instead of going to localhost: 3000 / api / router. it goes to localhost: 3000 / # / api / router and does not redirect.

    
asked by Kevin AB 07.06.2016 в 06:45
source

1 answer

-1

You must specify in the header that you add '/' instead of '#'. Add this line: < base href="/" / >

For example:


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

</head>

You must also enable the html5 mode.

app.config(["$locationProvider", function($locationProvider) {
  $locationProvider.html5Mode(true);
}]); 
    
answered by 08.06.2016 в 14:21