How to insert data in firebase using angularfire?

I have retrieved the data by injecting AngularFireDatabase object in constructor?I want to know how to add data to it

import { Component } from "@angular/core";
import { AngularFireDatabase } from "angularfire2/database";
import { Observable } from "rxjs/Observable";
@Component({
  selector: "app-root",
  templateUrl: "./app.component.html",
  styleUrls: ["./app.component.css"]
})
export class AppComponent {
  items: Observable<any[]>;

  itemsRef: any;
  constructor(db: AngularFireDatabase) {
    this.items = db.list("/").valueChanges();
    this.items.subscribe(console.log);
  }

 
}

It looks like this package uses promises for write operations.

https://github.com/angular/angularfire2/blob/master/docs/rtdb/objects.md

ok.i want to know i can insert data using this AngularFireDatabase or i have to use different object bcoz that documentation seems vague to me…

The docs there don’t seem vague to me. I don’t know what to tell you. How familiar are you with ES6? There is a section in those docs “Saving data” that outlines the interface to save data. It doesn’t use RxJs but standard ES6 promises. Are you familiar with promises?

yep i will take a look

This is a good read. Angular uses RxJs but RxJs is essentially a extension of promises. RxJs and the concept of asyncronous programming are the backbone of Angular.

Here is a good sitepoint article about promises.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.