Working on a project and it is the first time implementing ui-router. The situation is, I have parent child states and all childs share same controller because all are working on same domain(CRUD).
The problem is, I am on list page where I click edit option and then state changes to
/states/edit/1
Fine, but all my list, edit and update functions are in same controller. When state changes to states.edit I want to be able to pass parameters from list child state
states.list
to
states.edit
I am unable to get params in edit state. Here is the code:
$stateProvider.state('/dashboard', {
url: "/",
templateUrl: "/partials/dashboard.html"
})
.state('states', {
abstract:true,
url: "/states",
templateUrl: "/partials/manage-state.html",
controller:"stateManagementContrlr"
})
.state('states.list', {
url: "",
templateUrl: "/partials/state.list.html"
})
.state('states.create', {
url: "/create",
templateUrl: "/partials/create-state.html"
})
.state('states.edit', {
url: "/edit/:stateId",
templateUrl: "/partials/create-state.html",
})
What am I doing wrong ? Problem 1: How to get stateParams passed from one child state to another. Problem 2 : How to trigger a function when state changes?(State change listener good idea ?)
Be carefull I want to handle all this with one controller only . Please help me Thanks!