My app.component.ts is as follows
import { Component } from '@angular/core';
import { AngularFireDatabase, FirebaseListObservable, FirebaseObjectObservable } from 'angularfire2/database';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
list: FirebaseListObservable<any[]>;
// listing: FirebaseObjectObservable<any[]>;
constructor(private af:AngularFireDatabase) {
this.list=this.af.list('/listings');
// this.addTask();
}
addTask(){
this.list.push({
name: 'Aswin',
city:'kochi',
bedrooms:'[email protected]',
image:'9562096886',
path:'10',
price:'java',
title:'3',
type:'adipoli aanu'
});
}
}
My view page is like this
<input type="submit" (click)="addTask()"/>
Now when clicking the submit button it will push the values to angular2 firebase database.But the key name is random like KmMlBPniR8wpcyBMDOz.
I want to make the key should be custom,ie i want to give my own key name.how it should be possible,please help me?
Thanks in advance.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…