Da quando l'aggiornamento da Angular 1.3.0 RC-2 a RC-3 ha cancellato l'hash-sign nei collegamenti generati da ui-sref. Il collegamento è selezionabile e il trasferimento dello stato avviene correttamente, ma se copio l'indirizzo del link e lo incollo in un browser, verrà visualizzato sulla pagina sbagliata. Non voglio usare HTML5Mode.Ui-sref che non genera hash nell'URL (Angular 1.3.0-rc.3)
1.3.0-rc.2
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css">
</head>
<body ng-app="myApp">
<div ui-view></div>
<script src="https://code.angularjs.org/1.3.0-rc.2/angular.js"></script>
<script src="https://rawgit.com/angular-ui/ui-router/0.2.11/release/angular-ui-router.js"></script>
<script>
angular.module('myApp', ['ui.router'])
.config(function($stateProvider, $urlRouterProvider, $locationProvider) {
$urlRouterProvider.otherwise('/foo');
$stateProvider.state('foo', {
url: '/foo',
template: 'This is foo <a ui-sref="foo.bar">Go to bar</a><div ui-view></div>'
})
.state('foo.bar', {
url: '/bar',
template: 'This is bar'
})
$locationProvider.html5Mode(false);
//$locationProvider.html5Mode({ enabled: false })
});
</script>
</body>
</html>
Plunkr demonstrating working example
1.3.0-rc.4
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css">
</head>
<body ng-app="myApp">
<div ui-view></div>
<script src="https://code.angularjs.org/1.3.0-rc.4/angular.js"></script>
<script src="https://rawgit.com/angular-ui/ui-router/0.2.11/release/angular-ui-router.js"></script>
<script>
angular.module('myApp', ['ui.router'])
.config(function($stateProvider, $urlRouterProvider, $locationProvider) {
$urlRouterProvider.otherwise('/foo');
$stateProvider.state('foo', {
url: '/foo',
template: 'This is foo <a ui-sref="foo.bar">Go to bar</a><div ui-view></div>'
})
.state('foo.bar', {
url: '/bar',
template: 'This is bar'
})
//$locationProvider.html5Mode(false);
$locationProvider.html5Mode({ enabled: false })
});
</script>
</body>
</html>
Plunkr demonstrating the problem
sto facendo qualcosa di sbagliato, o è ui-router non compatibile con l'ultima release candidate di Angular?
era un segno di spunta rapido. heh –
Ho taggato una versione preliminare di 0.2.12: http://bit.ly/UIR-0212pre1 –