I am trying to find a way to refresh only the nested view of my application and add a route parameter in order to enable URL routing. However, I am struggling to achieve this. Initially, I had it working using a query like the following:
$location.search('userId', user._id);
//http://localhost:9000/#/user/?userId=123456789
The URL format that I am aiming for is as follows, with the userId = 123456789
:
http://localhost:9000/#/user/123456789
This is an excerpt from my app.js file:
$stateProvider
.state('index', {
url: '/',
views: {
'@' : {
templateUrl: 'views/layout.html'
},
'top@index' : {
templateUrl: 'views/top.html',
controller: function($scope, $state) {
$scope.userLogOut = function() {
$state.go('login');
};
}
},
'left@index' : { templateUrl: 'views/left.html' },
'main@index' : { templateUrl: 'views/main.html' }
}
})
.state('index.user', {
url: 'user:userId',
templateUrl: 'views/user/user.html',
controller: 'UserCtrl'
})
.state('index.user.detail', {
url: '/',
views: {
'detail@index' : {
templateUrl: 'views/user/details.html',
controller: 'DetailCtrl'
}
}
})
Within my controller:
$state.reload('index.user.detail', {userId: $scope.user._id});