Trying to switch between child views, however ui-sref generate a wrong url when the other child is already loaded. The correct link: 'template/viewname.html' The actual link: 'home/template/viewname.html' How to stop ui-sref from adding 'home/' to the link ? Thanks
app
angular.module('app',[,'ngRoute','ui.router']);
config
angular.module('app').config(['$urlRouterProvider', '$stateProvider', '$locationProvider', function ($urlRouterProvider, $stateProvider, $locationProvider) {
$locationProvider.html5Mode({
enabled: true,
requireBase: false
});
$urlRouterProvider.otherwise('/');
$stateProvider.state('home', {
url: '/home',
templateUrl: 'template/index.html',
controller: 'contr'
})
.state('home.about', {
parent:'home',
url: '/about',
templateUrl: 'template/about.html',
controller: 'contr'
})
.state('home.contact', {
parent: 'home',
url: '/contact',
templateUrl: 'template/contact.html',
controller: 'contr'
}) }]);
Home page
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8" />
</head>
<body>
<h3>Home</h3>
<div>
<a ui-sref="home.about">abouttt</a>
<a ui-sref="home.contact">contact</a>
</div>
<div ui-view>
</div>
</body>
</html>