Answer the question
In order to leave comments, you need to log in
How to build complex Url, store and transfer their state?
Hello!
I am making an app and there is a need to build links like /stateA/IdA/stateB/IdB with which the problem actually arose
What I do:
* directives with local scopes in templates, configs with states in controllers
.state(stateZero, {
url: '/list',
template: < table config="config"> < /table>,
controller: function () {}
})
.state(stateA.listA, {
url: '/list/:id',
template: < table id = 'id' config="config"> < /table>,
controller: function () {}
})
.state(stateB.listB, {
abstract: true,
url: '/list/:prevID/listB/:id',
template: < tabs id = "id" prevID = "prevID" config="config"> < /tabs>,
controller: function () {}
})
.state(stateB.listB.tabA, {
abstract: true,
url: '/tabA',
template: < input id = "id" prevID = "prevID" config="config"> < /input>,
controller: function () {}
})
<button ui-sref="{{state.sref}}({id:id, prevID: prevID})"
Answer the question
In order to leave comments, you need to log in
I sketched an exemplary implementation: Plnkr
To track state changes and pull parameters from the states of descendants, you can use this option:
controller: function($state, $scope, $rootScope) {
$rootScope.$on("$stateChangeStart", function() {
$scope.stateParams = $state.params;
});
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question