0

Once my child state controller gets instantiated it does not reload again on $state.go

my router layout

.state('hotelsearch', {
            url: '/search',
            abstract: true,
            views:{
                '': {
                templateUrl: "app/components/layout/layout.html"
                },
                "header@hotelsearch": {
                    templateUrl: "app/components/search/search.html"
                },

                "footer@hotelsearch": {
                    templateUrl: "app/components/footer/footer.html"
                }

             }

        })
        .state('hotelsearch.hotel', {
            url: '',
            views:{
            '':{templateUrl: 'app/components/search/searchHotel.html'},

        }
        })
        .state('hotelsearch.hotel.main', {
            url: '',
            views:{
                "main@hotelsearch": {
                    templateUrl: 'app/components/hotel/hotelSearch.html',
                    controller:"hotelResult"
                },  

        },

        })
        .state('hotelsearch.flight', {
            url: '',
            templateUrl: 'app/components/search/searchFlight.html',
        })

layout

<div ui-view="header"></div>
<div ui-view="main"></div>
<div ui-view="footer"></div>

state called on successfully resolving promise

.then(function(response){
        console.log(response.data.message);
        if(response.data.message==="Success"){
          $state.go('hotelsearch.hotel.main');

        }

controller hotelResult

function hotelResult(dataservice,$scope,$stateParams){
    console.log($stateParams);
    dataservice.makeRequestForHotel()
                    .then(function(response){
                        console.log(response);
                        $scope.data=response.data.HotelGroup[0].City;
                    });
}

i know the controller is not reloading a second time because console.not working.

What i have tried:

    1.using resolve.
    2.reload:true in `$state.go` (this causes the entire view controllers to be reloaded, as a result i get the data but the data in the suggestion box of search controller is lost)

what i am looking for is only selective reloading of the an individual state child controller

Hemant
  • 69
  • 2
  • 10
  • *Maybe, before you will get your answer, check this http://stackoverflow.com/a/25678843/1679310... there is also working plunker, which could help to understand how the overall UI-Router nesting and multi view is working* – Radim Köhler May 10 '16 at 13:03
  • sir, did study the links. however was not able to figure out a solution to my problem. is there some error the way the routing has been designed? – Hemant May 10 '16 at 13:47
  • In case you will create a plunker, I am ready to assist. Meanwhile, I can say.. I do not understand why url is set to "" almost everywhere. That won't help to decide the state. Child controller can be reloaded selectively, but only as a whole state change (child state) not just a view (as a part of a parent state multi-views) – Radim Köhler May 10 '16 at 13:49
  • sir, my understanding of url parameter is as to how it will show in the browser url. so i felt it not necessary to set it now. will create a plunker – Hemant May 10 '16 at 13:58

0 Answers0