This listener works great:
firebase.firestore().collection('Users').doc($scope.user.uid).collection('Spanish').doc('Word_Response').onSnapshot(function(wordResponse) {
But we have more languages than Spanish. This listener doesn't work:
firebase.firestore().collection('Users').doc($scope.user.uid).collection($scope.longLanguage).doc('Word_Response').onSnapshot(function(wordResponse) {
$scope.longLanguage
is set to American_English
when the app loads and the listener starts listening. The user can switch to Spanish, Mandarin, Finnish, etc., which changes $scope.longLanguage
. The problem is that in the listener the variable $scope.longLanguage
doesn't change. Can we change the collection on the fly, or do we have to write listeners for every language, i.e., for every collection?
The documentation says that we can listen to multiple documents in a collection (using the where
filter) but doesn't say that we can listen to multiple collections.