In my abstract root state named 'site', the empty URL ('') contains two child states: 'profile' and 'home'. The URL for home is '/', while the URL for profile is '/{username:[a-zA-Z0-9]{3,20}}'. I have encountered an issue where despite trying multiple times to navigate to the profile state, it always redirects me to the home state.
However, when I modify the home state
URL to something like '/home'
, I am then able to access the profile state
. After searching online, I could not find any information on this particular problem. Could this be a bug or am I missing something in my implementation?
Below is the code snippet for $stateProvider
:
$stateProvider.
state('site', {
url: '',
abstract: true,
views: {
'': {
templateUrl: 'views/site.html'
},
'navbar@site': {
templateUrl:'views/navbar.html'
}
},
data:{
access: access.public
}
}).
state('site.home', {
url: '/',
templateProvider :['$rootScope','$http','$state',function($rootScope,$http,$state){
var template = 'views/main_new.html';
if($rootScope.User.isLoggedIn()){
template = 'views/new_room_me.html'
}
return $http.get(template).then(function (resp) {
return resp.data;
});
}]
}).
state('site.profile',{
url:'/{username:[a-z0-9A-Z]{3,20},strict:true}',
templateUrl:'views/new_room_friend.html'
});
$urlRouterProvider.otherwise('/ankit');