Can you target a specific child of a FirebaseObjectObservable in Angular? Take a look at RcTestAppComponent.save()
function below for commented lines.
Here is an example: https://github.com/angular/angularfire2/blob/master/docs/3-retrieving-data-as-lists.md
import { Component } from '@angular/core';
import { AngularFire, FirebaseObjectObservable } from 'angularfire2';
@Component({
moduleId: module.id,
selector: 'app',
template: `
<h1>{{ item | async | json }}</h1>
<input type="text" #newname placeholder="Name" />
<input type="text" #newsize placeholder="Size" />
<br />
<button (click)="save(newname.value)">Set Name</button>
<button (click)="update(newsize.value)">Update Size</button>
<button (click)="delete()">Delete</button>
`,
})
export class RcTestAppComponent {
item: FirebaseObjectObservable<any>;
constructor(af: AngularFire) {
this.item = af.database.object('/item');
}
save(newName: string) {
this.item.set({ name: newName });
/*
// Is it possible to do something like this:
let index = 2;
this.item.child(index).set({ name: newName });
// index can be dynamic;
// When attempting to use .child() on this.item, I encounter an error:
// TypeError this.item.child is not a function
*/
}
update(newSize: string) {
this.item.update({ size: newSize });
}
delete() {
this.item.remove();
}
}
Thank you