I have a number of slideboxes in a view. The first slidebox has several possible values and the second is dependent on the selected value of the first.
I’ve tried the following code to try and get the content on the page to update nicely but there seems to be some kind of race condition preventing proper rendering:
$scope.beacon = {};
$scope.missions = missions.results
$scope.platforms = platforms.results
$scope.regions = regions.results
// set up the initial levels value - this will change as users scroll through missions
$scope.levels = $scope.missions[0].levels
$ionicSlideBoxDelegate.update();
// Called when the form is submitted
$scope.createBeacon = function() {
$scope.beacon = BeaconService.save({
mission : UtilsService.getObjectAsPointer( 'missions', $scope.missions[$ionicSlideBoxDelegate.$getByHandle('mission-selector').currentIndex()].objectId ),
fireteam : $ionicSlideBoxDelegate.$getByHandle('fireteam-selector').currentIndex() + 1,
platform : UtilsService.getObjectAsPointer( 'platforms', $scope.platforms[$ionicSlideBoxDelegate.$getByHandle('platform-selector').currentIndex()].objectId ),
region : UtilsService.getObjectAsPointer( 'regions', $scope.regions[$ionicSlideBoxDelegate.$getByHandle('region-selector').currentIndex()].objectId )
})
};
$scope.missionChanged = function( index ) {
$scope.levels = $scope.missions[index].levels;
$ionicSlideBoxDelegate.$getByHandle('level-selector').update();
}
I’ve also tried replacing the missingChanged function with this to no avail:
$scope.missionChanged = function( index ) {
$scope.levels = $scope.missions[index].levels;
setTimeout(function() {
$ionicSlideBoxDelegate.$getByHandle('level-selector').update();
}, 1000);
}
I’ve even managed to record a couple of gifs to show the behavioural oddities:
- This one shows the version without the timeout: http://recordit.co/rkhwLO2YUG
- This one shows the version with the timeout: http://recordit.co/ePbDpP5Y79
Worth mentioning a few things in case it has an impact; All “Missions” except Crucible have one or more level. Aside from Crucible, you should always see a level in the second slidebox.