Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data item array duplicated in app when add or delete from data from firebase #1929

Closed
murtadaalwaely opened this issue Oct 21, 2018 · 2 comments

Comments

@murtadaalwaely
Copy link

murtadaalwaely commented Oct 21, 2018

"angularfire2": "^5.0.2",
"firebase": "^5.5.5",
"ionic-angular": "3.9.2",
"angular/compiler": "5.2.11",,
"angular/fire": "^5.0.2",

I am using angularfire2 with ionic3 to send and get data realtime from firebase.
I have used this command to install it and it worked
npm install firebase @angular/fire --save

retrieve data is working by using this code

this.categorieslistitems= this.db.list('/categories', ref => ref.orderByChild('title')); this.categorieslistitems.snapshotChanges().subscribe(actions => { actions.forEach(action=>{ let ky = action.payload.toJSON() ky['key'] = action.key this.categoriesitemArray.push(ky as postdata1)})})
`
export interface postdata1 {

key?: string;
title:string;
img:string;

}
`
using open firebase security rules

now I am getting data from firebase correctly ,
but when I add or delete data from firebase ,my item array or my list getting duplicated in the app only ,and its not duplicated in the database ,when i refresh the app its return normal

adding only the last data have inserted to firebase in realtime

data getting duplicated in app only with adding the new recorded with the duplicated record

1
2
3

@alberthoekstra
Copy link

Where do you clear the this.categoriesitemArray ?

Why don’t you use the observable?

@jamesdaniels
Copy link
Member

Closing as outdated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants