2016-12-19 10 views
3

日付をプロパティとして自動的にFirebaseにプッシュできますか? alertcontrolメソッドで本を追加する関数です。投稿時に投稿日を取得するには?

addBook() { 
console.log("add book button click-ed"); 

let alert = this.alertCtrl.create({ 
    title: 'Book Title and Author', 
    message: 'Book Cover', 
    inputs: [ 
    { 
     name: 'title', 
     placeholder: 'Book Title' 
    }, 
    { 
     name: 'author', 
     placeholder: 'Author of the Book' 
    }, 
    { 
     name: 'cover', 
     placeholder: 'Cover URL' 
    }, 
    ], 
    buttons: [ 
    { 
     text: 'Cancel', 
     handler: data => { 
     console.log('Cancel click-ed') 
     } 
    }, 
    { 
     text: 'Save Book', 
     handler: data => { 
     this.books.push({ 
      title: data.title, 
      author: data.author, 
      cover: data.cover, 
     }) 
     } 
    } 
    ] 
}) 
alert.present(); 

}

私は、タイトル、著者、およびカバーのための小道具の入力を設定しました。それはうまく動作します。 addBook()関数は、そのメソッドを持つボタンにバインドします。しかし、ユーザがボタンをクリックしたときに投稿日を取得し、Firebaseに小道具の日付として追加したい場合、どうすればいいですか?

答えて

関連する問題