I have a main list page, when click on each post, it leads to a separate page with its own detail. That part of the UI-router works fine.
I also have another page state whereby upon clicking a username (with link on main page as well as each detail page), it should bring user to a profile page of that user based on a userId.
Whats wrong with the codes at the profile state? Ive tried many permutations and even blank '' states as per view@state structures but it always jumps back to the URL.otherwise url. I read up on the github states but and am clear on the rules but somehow I cant seem to figure this out. Does it mean I need 2 states for 2 different links leading to the same profile page view?
html for link to user profile by Id
ng-href="#/users/{{ user.profile.uid }}
or
ui-sref="tab.posts/users/{{ user.profile.uid }}"
.
The app.js states file
.state('tab', {
url: '/tab',
abstract: true,
templateUrl: 'templates/tabs.html'
})
.state('tab.posts', {
url: '/posts',
views: {
'tab-posts': {
templateUrl: 'templates/tab-posts.html',
controller: 'PostsCtrl'
}
}
})
.state('tab.posts.view', {
url: '/:postId',
views: {
'tab-posts@tab':{
templateUrl: 'templates/tab-showpost.html',
controller: 'PostViewCtrl'
}
}
})
.state('tab.profile', {
url: '/users/:userId', //tried url = '/:userId', doesnt work
views: {
'tab-posts@tab': { // tried many permutations here too
templateUrl: 'templates/profile.html',
controller: 'ProfileCtrl'
}
}
});
$urlRouterProvider.otherwise('auth');
});