Open shin10kudev opened 7 years ago
Suggested by another user:
SERVICE import { Injectable, Inject } from '@angular/core'; import { AngularFireDatabase } from 'angularfire2/database'; @Injectable() export class FirebaseUtilityService { newKey: string; constructor(private db: AngularFireDatabase) { } createUniqueKey(model: string): string { return this.newKey = this.db.app.database().ref(model).push().key; } } USING THE SERVICE this.$key = this.generateNewKey(firebaseRef); generateNewKey(firebaseRef: string): string { return this.$key = this.firebaseService.createUniqueKey(firebaseRef); }
Suggested by another user: