Saturday 6 July 2019
angularjs - How to set abstract routes as children of an abstract route?
Answer
I am having a problem where my controllers are running before initialization of my app, and I came across this solution. The problem is I have several abstract routes and setting those abstract routes as children just breaks everything.
Here is some of the relevent code:
app.config(function($stateProvider, $urlRouterProvider, $locationProvider, stateHelperProvider){
$urlRouterProvider.otherwise('/venues/feed');
// $locationProvider.html5Mode(true);
stateHelperProvider.setNestedState({
name: 'root',
// url: '/root',
template: ' ',
abstract: true,
resolve: {
bootstrapper: function($http, $rootScope, $cookies) {
console.log('once upon a time')
return $http.get('/__/env.json')
.then(function(response) {
$rootScope.apiUrl = response.data.apiUrl;
$rootScope.googleMapsApiKey = response.data.googleMapsApiKey;
$rootScope.currentLocationLat = 40.7589;
$rootScope.currentLocationLng = 73.9851;
})
.then(function(){
hotelId = ''
if ($cookies.get('hotel') === undefined){
$http.get($rootScope.apiUrl + '/hotels')
.then(function(dbHotels){
hotelId = dbHotels.data[0]._id
$cookies.put('hotelId', hotelId)
})
}
if ($cookies.get('userId') === undefined){
$http.get($rootScope.apiUrl + '/users')
.then(function(dbUsers){
index = dbUsers.data.length - 1
userId = dbUsers.data[index]._id
$cookies.put('userId', userId)
$rootScope.$broadcast('update-itinerary-icon')
})
}
})
}
},
children: [{
name:'venues',
url: '/venues',
abstract: true,
template:''
},
{
name:'venues.feed',
url: '/feed?favorites&priceLevelMin&priceLevelMax',
reloadOnSearch: false,
templateUrl:'./views/venue/feed.html',
controller: 'VenueController'
}, {
name:'venues.details',
url: '/:venue_id',
templateUrl:'./views/venue/details.html',
controller:'VenueController'
}, {
...more routes...
}]
});
$locationProvider.html5Mode(true);
});
How to I get this solution to work with my routes?
Subscribe to:
Post Comments (Atom)
php - file_get_contents shows unexpected output while reading a file
I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...
-
I have an app which needs a login and a registration with SQLite. I have the database and a user can login and register. But i would like th...
-
I would like to use enhanced REP MOVSB (ERMSB) to get a high bandwidth for a custom memcpy . ERMSB was introduced with the Ivy Bridge micro...
-
According to my understanding, and my calculator, cos(90 degrees) equals 0 . In my code, I have a funct...
No comments:
Post a Comment