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