angularfire2

Querying subset from angularfire2

最后都变了- 提交于 2019-12-11 07:28:37
问题 I need to get a subset from a firebase list. Let's say I have two sets: set1 = { dog:true, cat:true, snake:true, bull:true } and set2 = { dog:true, cat:true } What I need is to get the "in set1, but not in set2", in this case it would return: setresult = { snake:true, bull:true } I tried to achieve this with map: this.setresult = this.af.database.list('/set2/').map((animals) => { return animals.map((animal) => { if (auth.uid == _user.$key || af.database.object('set2/' + animal.$key) == null)

Exporting firebase data and set it as default input in template driven form

让人想犯罪 __ 提交于 2019-12-11 07:28:33
问题 I am creating an app using angular 4.0.2, angularfire2, and firebase, off course. What the problem is I am not able to use the data from angularfire2 and set it as default input value of an input used in model-driven or reactive form. Here is my code for add-invoice.component.ts ngOnInit(){ const datafetch = firebase.database().ref().child('/invoices').orderByKey().limitToLast(1).once('value').then(snapshot => { const names = []; snapshot.forEach(function(childSnapshot) { var childKey =

How to handle promise in firestore

好久不见. 提交于 2019-12-11 07:25:57
问题 here is my code to check a doc is there in the collections this.shopCollection = this.afs.collection<Shop>('shops', ref => { return ref.where('fulladdress', '==', myString) }); i don't know why i can't use .then() and .catch() with this method. When i pass a string to query and if no result found how i know? I am using angularfire2 version ^5.0.0-rc.1 with angular ^4.2.4 and firebase ^4.5.0 . Please help. 回答1: I got it working with some changes Here is my code this.afs.collection<Shop>('shops

Get Item Name from ngFor

时光怂恿深爱的人放手 提交于 2019-12-11 06:44:11
问题 I am selecting from following list: <ion-select multiple="true" okText="Select" cancelText="Cancel" required [(ngModel)]="retailerItemModel" formControlName="retailerItem" name="retailerItem"> <ion-option *ngFor="let item of itemList | async" [value]="item.itemPrice"> {{item.itemName}}  Rs.{{item.itemPrice}} </ion-option> </ion-select> I am calculating the totalValue with item.itemPrice as [value] (mentioned above) but I want to fetch the item.itemName too.. I am getting correct value of

Combining multiple FirebaseListObservables

牧云@^-^@ 提交于 2019-12-11 06:27:33
问题 const placeId = this.getPlaceId(); this.af.database.list(`placeUsers/${placeId}`).subscribe((userKeys) => { for (let index = 0; index < userKeys.length; index++) { let userKey = userKeys[index]; this.af.database.list(`userDevices/${userKey.$key}`).subscribe((deviceKeys) => { for (let index = 0; index < deviceKeys.length; index++) { let deviceKey = deviceKeys[index]; this.af.database.object(`devices/${deviceKey.$key}`).subscribe((device) => { console.log(device); // Device received. }); } });

AngularFire2 App Init in Module Conflicts with Dynamic Config Data

谁说我不能喝 提交于 2019-12-11 06:19:33
问题 I have a problem due to my config data being loaded at runtime and AnuglarFire2 wanting the data in the module declaration. I can access the data via direct injection, but I cannot figure out how to get the data to AngularFireModule in my module file. Having the data loaded at runtime is the preferred way to get configuration data to the app. So, I cannot change this process. Therefore, I need to come up with a solution to the problem. AngualrFire2 Setup Page https://github.com/angular

Sort data descending list Firebase Angular2

懵懂的女人 提交于 2019-12-11 04:44:08
问题 Is it possible to sort values descending using Firebase in Angular2? In my example I want to use the timestamp field as the sort value. I have tried with this approach but haven't been succesfull in sorting it descending. this.items = af.database.list('/items', { query: { orderByChild: 'timestamp' } }); One option I can think of would be pushing these values to a new array as they arrive and then return that array but that seems suboptimal. 回答1: I'm not familiar with Firebase queries, but if

angularfire2: Type 'Observable<any[]>' is not assignable to type 'FirebaseListObservable<any>'

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 04:28:21
问题 Hi im new at angularfire2. Im trying to connect objects to an array (list) based on $key values. my current code looks like: console.log("Create Relationship Person 2 Person Observable"); const relationshipP2Ps$: FirebaseListObservable<any> = af.database.list('/relationshipP2P') // Primary list .map(items => { // `items` is an array of all items at the moment for (let item of items) { // Find each corresponding associated object and store it as a FibrebaseObjectObservable const i:

AngularFire httpsCallable Object(…) is not a function

左心房为你撑大大i 提交于 2019-12-11 02:58:37
问题 I want to call a httpsCallable function in my Ionic 3 app. I am attempting to follow these docs: https://firebase.google.com/docs/functions/callable I tried: const newGame = (firebase as any).functions().httpsCallable('findCreateGame'); newGame({}).then(function(result) { console.log("In here."); }); Which resulted in: ERROR TypeError: WEBPACK_IMPORTED_MODULE_5_firebase_functions .functions is not a function I also tried the newly implemented wrapper in angularfire: const newGame = this

How to get the firebase.User in AngularFire2

笑着哭i 提交于 2019-12-11 02:55:31
问题 I am using AngularFire2 (Ionic2) and Firebase Authentication. I am having a problem trying to get the current user. The works for me, but inconsistently. Sometimes it is populated, and sometimes it is null. let user: firebase.User = firebase.auth().currentUser; Is there a way to get the current user more consistently? More Info: I am logging in as follows: import { FirebaseAuth, AuthProviders, AuthMethods } from 'angularfire2'; public auth: FirebaseAuth this.auth.login({ provider: