0

I got lots of projects :

export class Project {
  $key: string;
  file: File;
  name: string;
  title: string;
  cat: string;
  url: string;
  progress: number;
  createdAt: Date = new Date();

  constructor(file: File) {
    this.file = file;
  }
}

I upload them all to :

  uploads: Observable<Project[]>;

  private saveFileData(upload: Project) {
    this.db.list(`profile/${this.auth.userId}/project`).push(upload);
}

And then I am trying to get one :

 uploads: Observable<Project[]>;
getOne(){
  this.uploads = this.db.list(`profile/${this.auth.userId}/project/${this.projectId}`);
}

In this case I get error on this.uploads

(Angularfirelist is not assignable to Observable.)

Then I tried this :

  uploads: AngularFireList<Project[]>;

getOne(){
  this.uploads = this.db.list(`profile/${this.auth.userId}/project/${this.projectId}`);
}

Error :

ERROR Error: InvalidPipeArgument: '[object Object]' for pipe 'AsyncPipe'

How to get that one project ?

1 Answer 1

1

Add valueChanges()to get only the data, or snapshotChanges() to get data's payload:

this.uploads = this.db.list(`profile/${this.auth.userId}/project/${this.projectId}`).valueChanges();
Sign up to request clarification or add additional context in comments.

8 Comments

It gets all strings as new objects.
But you use async pipe in template like - <div *ngFor="let item of uploads | async">?
I assume i need to use object not a list if I want to show only one
So you could do {{ uploads | async }}
Yes it worked, next question if you can help : How do I upload my project like this : project1/projec1 values, project2/project2 values,
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.