@magnogcs wrote:
Hi, I have multiple databases firebase, but I want to load the firebase configuration specific about the selected city in my home, for example:
I Have a list of citys
when I select a city, I want to capture in this button the value, and change my firebase configuration
my html:
<ion-list> <div class="item item-divider">Selecione sua cidade</div> <div class="item item-select" fancy-select ng-model="single1" items="selectable" item-label="fname"> {{single1.fname || 'Cidade selecionada'}} </div> <button class="button button-full" ng-click="vm.submit()">Enviar</button> </ion-list>my configuration:
"use strict"; angular.module('config', []) .constant('ENV', { name:'development', dataProvider:'FIREBASE', firebaseConfig:{ apiKey:'AIzaSyCfE-kOfvtPs8D7mDa7Mq8ykHXS08jkSY0', authDomain:'achou-cidades.firebaseapp.com', databaseURL:'https://achou-cidades.firebaseio.com' }, firebaseConfig2:{ apiKey:'AIzaSyB-6HEg5PMvAA3YKwx7xgRAiaJTqKFQzg4', authDomain:'achou-tubarao.firebaseapp.com', databaseURL:'https://achou-tubarao.firebaseio.com' }, youtubeKey:'AIzaSyDael5MmCQa1GKQNKQYypmBeB08GATgSEo', ionicPrivateKey:'a9265eaf15a20cc8516c770e8748aeed4891b28f453ce755', ionicPublicKey:'e30d4d540b8c75d1f167bbf242423c3fb23fe10275d1c016', ionicAppId:'241b6d37', gcmId:'228071472080' }, ) ;(firebaseConf1 is a city, and firebaseConfig2 is other city, for example.
here is where I call the configuration:
angular .module('listing.common') .factory('db', ['ENV', function(ENV) { firebase.initializeApp(ENV.firebaseConfig); return firebase.database().ref() }]) .factory('firebaseDataService', firebaseDataService);So… I want to change de firebase.initializeApp when I change de select for example… if (selected city = 1) ENV.firebaseConfig… else if (selected city = 2) ENV.firebaseConfig2… Any idea? or other solution for case? Thanks!
Posts: 1
Participants: 1

