I am stucked with one problemm. I have one template URL but alot of variant of state. I have one parent state and other states is the childs. now it seens like this:
angular
.module("StN")
.config(config);
function config($stateProvider) {
$stateProvider
.state("invoice", {
url: "/invoice",
templateUrl: "/Scripts/js/stn/invoice/invoice.html",
controller: "invoiceController as vm"
})
.state("invoice.custom", {
url: "/castom"
})
.state("invoice.search", {
url: "/search?Status?Invoice?"
});
}
And in the controller I have switch case construction, where I check current state name and do some difference logic
angular
.module("StN")
.controller("invoiceController", invoiceController);
function invoiceController($http, $state) {
switch (state.name) {
case "invoice.search":
//first logic
break;
case "invoice.custom":
//second logic
break;
case "invoice.status":
//third logic
break;
}
}
I need to have different controller for each state, but this controllers must have logic of parent controller (invoiceController). How can I do that?
Example
.state("invoice", {
url: "/invoice",
templateUrl: "/Scripts/js/stn/invoice/invoice.html",
controller: "invoiceController as vm"
})
.state("invoice.custom", {
url: "/castom"
controller: "DerivedinvoiceController as vm" //but it must have logic of base controller
})