Reputation: 352
I got a current angularjs application using the standard $routeProvider for routing. I intend to use a part of the application the $stateProvider for a wizard.
I declared a parent state 'Modal' and a child state 'editClient' like this:
$stateProvider.state('Modal', {
views: {
'modal': {
templateUrl: '*urlHere*',
controller: '*controllerHere'
}
},
abstract: true
});
$stateProvider.state('Modal.editClient', {
views: {
"modal": {
url: '/editClient/:id',
templateUrl: '*templateHere*',
controller: '*controllerHere*'
}
}
});
In my controller I call:
$state.go('Modal.editClient', { id: 1});
Yet $stateParams is empty. How come?
I'm using angular-ui-router version 0.2.15 and angularjs 1.2.25. Updating to a higher angularjs version is not possible at the moment.
Update
I also tried:
$stateProvider.state('Modal.editClient', {
views: {
"modal": {
params: {
'id' : 0
},
templateUrl: '*templateUrlHere*',
controller: '*controllerHere*'
}
}
});
Upvotes: 1
Views: 102
Reputation: 4578
You are not passing argument in state where you are defining your states you need to do something like this.
$stateProvider.state('Modal', {
views: {
'modal': {
templateUrl: '*urlHere*',
controller: '*controllerHere'
}
},
abstract: true
});
$stateProvider.state('Modal.editClient', {
params: {
'id': 0
},
views: {
"modal": {
url: '/editClient/:id',
templateUrl: '*templateHere*',
controller: '*controllerHere*'
}
}
});
Upvotes: 2