UI: Improve state controller API.
This commit is contained in:
parent
eecca6e47a
commit
b339218fed
@ -28,6 +28,8 @@ export default function DefaultStateController($scope, $timeout, $location, $sta
|
||||
vm.getStateObject = getStateObject;
|
||||
vm.navigatePrevState = navigatePrevState;
|
||||
vm.getStateId = getStateId;
|
||||
vm.getStateIndex = getStateIndex;
|
||||
vm.getStateIdAtIndex = getStateIdAtIndex;
|
||||
vm.getStateParams = getStateParams;
|
||||
vm.getStateParamsByStateId = getStateParamsByStateId;
|
||||
vm.getEntityId = getEntityId;
|
||||
@ -100,6 +102,22 @@ export default function DefaultStateController($scope, $timeout, $location, $sta
|
||||
}
|
||||
}
|
||||
|
||||
function getStateIndex() {
|
||||
if (vm.stateObject && vm.stateObject.length) {
|
||||
return vm.stateObject.length-1;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
function getStateIdAtIndex(index) {
|
||||
if (vm.stateObject && vm.stateObject[index]) {
|
||||
return vm.stateObject[index].id;
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
function getStateParams() {
|
||||
if (vm.stateObject && vm.stateObject.length) {
|
||||
return vm.stateObject[vm.stateObject.length - 1].params;
|
||||
|
||||
@ -30,6 +30,8 @@ export default function EntityStateController($scope, $timeout, $location, $stat
|
||||
vm.getStateObject = getStateObject;
|
||||
vm.navigatePrevState = navigatePrevState;
|
||||
vm.getStateId = getStateId;
|
||||
vm.getStateIndex = getStateIndex;
|
||||
vm.getStateIdAtIndex = getStateIdAtIndex;
|
||||
vm.getStateParams = getStateParams;
|
||||
vm.getStateParamsByStateId = getStateParamsByStateId;
|
||||
vm.getEntityId = getEntityId;
|
||||
@ -108,6 +110,22 @@ export default function EntityStateController($scope, $timeout, $location, $stat
|
||||
}
|
||||
}
|
||||
|
||||
function getStateIndex() {
|
||||
if (vm.stateObject && vm.stateObject.length) {
|
||||
return vm.stateObject.length-1;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
function getStateIdAtIndex(index) {
|
||||
if (vm.stateObject && vm.stateObject[index]) {
|
||||
return vm.stateObject[index].id;
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
function getStateParams() {
|
||||
if (vm.stateObject && vm.stateObject.length) {
|
||||
return vm.stateObject[vm.stateObject.length - 1].params;
|
||||
|
||||
@ -72,6 +72,22 @@ export default function StatesComponent($compile, $templateCache, $controller, s
|
||||
}
|
||||
}
|
||||
|
||||
stateController.getStateIndex = function() {
|
||||
if (scope.statesController) {
|
||||
return scope.statesController.getStateIndex();
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
stateController.getStateIdAtIndex = function(index) {
|
||||
if (scope.statesController) {
|
||||
return scope.statesController.getStateIdAtIndex(index);
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
stateController.getStateParams = function() {
|
||||
if (scope.statesController) {
|
||||
return scope.statesController.getStateParams();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user