3
votes

I am using angular ui router, and have a parent abstract state ("home") and two child state ("home.ports" and "home.editPort"). state. "home.state" is a default state, so on page refresh when the home.state loads it first trigger the parent ("home") state which in turn trigger the http request in the resolve property. My child state can me make changes on the server and can update the list of the parent state. So, the problem is when I am going to child state ("home.editPort") and come back to home.ports its not triggering the home state to fetch the updated listing

.state('home', {
    url: "/home",
    templateUrl: "dest/partials/home/_home.html",
    controller: "HomeController",
    abstract : true,
    data: {
        requireLogin: true
    },
    resolve: {
        // making an http request
        jqTreeData : ['httpService', 'BASE_HOME_URL', function (httpService, BASE_HOME_URL) {
            var obj = {
                    url : BASE_HOME_URL + "emulationDetails",
                    responseType : "json",
                    method : "GET"
                };
            return httpService.makeAjax(obj);
        }]
    }
})
.state('home.ports', {
    url: "/ports",
    //templateUrl: "dest/partials/home/ports/_portList.html",
    template: "<custom-Table tbl-Caption='Port Listing'></custom-Table>",
    controller: "PortsListController"
})
.state('home.editPort', {
    url: "/editPort",
    template: "<h1>Edit ports</h1>"
});
1
how you are redirecting child state? - Pankaj Parkar
i have few links (anchor tag) in my app, when user clicks on any of it the respective state is triggered ($state.go(...)) - atul bajpai

1 Answers

0
votes

The resolve only gets called when the home state is entered - because you are navigating between home.ports and home.editPort and both are child states of home - you are never actually leaving the home state - so resolve wont be called again - you are still within that state.

you might need to make another call to the service for fetching data which is triggered by the completion of tasks in the home.editPort state.