本文整理匯總了TypeScript中angularfire2/angularfire2.FirebaseListObservable.push方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript FirebaseListObservable.push方法的具體用法?TypeScript FirebaseListObservable.push怎麽用?TypeScript FirebaseListObservable.push使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類angularfire2/angularfire2.FirebaseListObservable
的用法示例。
在下文中一共展示了FirebaseListObservable.push方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: saveEvent
saveEvent(event: EventModel): EventModel {
if (!event) {
return null;
}
if (event.$key) {
this.events$.update(event.$key, _.omit(event, ['$key', '$exists']));
} else {
this.events$.push(event);
}
return event;
}
示例2: save
save(name:string,
length:string,
key:string,
tempo:string,
artist:string,
genre:string,
lyrics:string,
notes:string,
other:string
){
if(this.isNew === true){
//this.artists.map( artists => artists.filter(artist => artist.name === artist.name));
var newItemKey = this.songs.push({name:name,length:length,key:key, tempo:tempo,lyrics:lyrics, uid:this.uid}).key;
}
else
{
this.getOrCreateArtist(artist).then(
function(result){
var artistKey;
if(result){
artistKey = result['$key'];
}
else{
artistKey = this.artists.set({name:artist}).key;
}
/*const user = this.af.database.object(`users/${login}`);
user.subscribe(data => {
if(data.$value !== null) {
console.log('User does not exist');
} else {
console.log('User does exist');
}
});*/
this.song.update({name:name,length:length,key:key, tempo:tempo, lyrics:lyrics, artistId:artistKey});
}
);
}
this.router.navigate(['/songs']);
}
示例3: saveTrack
saveTrack(track: TrackModel, kml?: string): TrackModel {
// Should save a new KML or keep existing ?
let kmlObject = {};
if (kml) {
console.debug('Saving a new KML', kml);
kmlObject = {kml: this.saveKml(kml).key};
}
const newTrack: TrackModel = Object.assign(
{},
track,
kmlObject);
if (newTrack.$key) {
console.debug('Update track');
this.tracks$.update(newTrack.$key, _.omit(newTrack, ['$key', '$exists']));
} else {
console.debug('Create a new track');
this.tracks$.push(newTrack);
}
return newTrack;
}
示例4: saveKml
saveKml(kml: string): firebase.database.ThenableReference {
return this.kmls$.push(kml);
}
示例5: getNewTaskListID
/**
* Generates and returns a unique id for a task list.
* @returns {string}
*/
private getNewTaskListID(): string {
let taskLists: FirebaseListObservable<any[]> =
this.angularFire.database.list(TASK_LIST_METADATA_PATH);
return taskLists.push(null).key;
}