Reputation: 2671
I want to redirect from a parent state to a particular child state all the time. Please refer below :
$stateProvider.state('dashboard.view-bills', {
url: '/individual/view-bills',
templateUrl: 'modules/view-bill-module/partial/current-invoices/current-invoices.html',
ncyBreadcrumb: {
label: ' View Bills'
}
});
$stateProvider.state('dashboard.view-bills.current-invoices', {
url: '/current-invoices',
templateUrl: 'modules/view-bill-module/partial/current-invoices/current-invoices.html',
ncyBreadcrumb: {
label: ' Current Invoices'
}
});
$stateProvider.state('dashboard.view-bills.history-invoices', {
url: '/invoices',
templateUrl: 'modules/view-bill-module/partial/history-invoices/history-invoices.html',
ncyBreadcrumb: {
label: ' Invoice History'
}
});
Here, I want to go the 'dashboard.view-bills.current-invoices' state whenever I am in dashboard.view-bills
state. I am using angular-breadcrumb from breadcrumbs.
I have used the following code to change the URL :
$urlRouterProvider.when('/individual/view-bills' , '/individual/view-bills/current-invoices');
But with this code, the state doesn't change, What is the best way of doing this ? And also, is there any function like : $stateRouterProvider.when('matcher-state' , 'destination-state');
Upvotes: 1
Views: 778
Reputation: 15719
Keep the line $urlRouterProvider.when('/individual/view-bills' , '/individual/view-bills/current-invoices')
, you have done half of the job.
What are you missing is the abstract: true
in state dashboard.view-bills
to make the state change.
Thanks for using angular-breadcrumb, btw ;)
Upvotes: 1