【发布时间】:2014-10-29 11:51:56
【问题描述】:
我在 Angular 中编写了一个表单,它将表单中提交的数据发送到我的 Firebase 中一个名为 places 的对象。
HTML
<form role="form" name="addPlaceForm" ng-submit="createHospital(newHospital)">
<input type="text" placeholder="Enter title here" ng-model="newHospital.title">
<button type="submit" class="btn btn-primary btn-lg">Submit</button>
</form>
JS
var rootRef = new Firebase('URL');
var placesRef = rootRef.child('places');
function createHospital(hospital) {
placesRef.push(hospital);
}
有没有一种方法可以在提交时将名为 created_at 的生成时间戳推送到我的 places 对象?
"created_at" : "2014-07-15T01:52:33Z"
还有其他自动化数据,例如推送唯一 ID。
对此的任何帮助将不胜感激。提前致谢!
【问题讨论】: