I recently discovered a David East firebase blog post and started migrating my downloaded usage from my controllers to my permissions for each view. One of the problems that came up is when I retrieve $ firebaseArray with firebaseRef that contains something from another firebase database call. My referent for the second part will be something like this:
var chatRef = firebase.database().ref('messages/'+thisGroup.groupId+'/main');
Is this a situation where I can only deploy one promise through a solution, or I close up doing something like this (ActiveGroup is a service that returns a firebaseObject for the currently selected group):
.state('tab.chats-main', {
url: '/chats/main',
cache: true,
views: {
'tab-chats': {
templateUrl: 'templates/tab-chatsTopic.html',
controller: 'ChatsTopicCtrl'
}
},
resolve: {
currentAuth: authRequire,
posts: function($firebaseArray, currentAuth, ActiveGroup){
var thisGroup = ActiveGroup(currentAuth.uid);
thisGroup.$loaded().then(function(){
var chatRef = firebase.database().ref('messages/'+thisGroup.groupId+'/main');
return $firebaseArray(chatRef.limitToLast(100)).$loaded();
})
}
}
})
And here I entered the messages into the controller:
.controller('ChatsTopicCtrl', function($scope, thisGroup, posts, profile, chatName, chatMessages, currentAuth, ActiveGroup, $cordovaCamera, $ionicScrollDelegate, $ionicModal, $ionicActionSheet, $timeout,$state, moment) {
console.log("what are posts? ",posts);
Thanks in advance!