【问题标题】:Simple form submission angular & Firebase简单的表单提交 Angular 和 Firebase
【发布时间】:2016-09-02 23:58:55
【问题描述】:

我无法向 Firebase 提交表单。我尝试过使用不同的事件侦听器和调用函数的方法,但无法将数据获取到 firebase。这是我目前拥有的

var firebaseRef = new Firebase("https://site.firebaseio.com/things");
var postRef = firebaseRef.push();

$scope.submitPost = function(){
    firebaseRef.push = ({Title: $scope.title, Description:   $scope.moreinfo, Email: $scope.email, Number: $scope.number, Date: $scope.rtime});
    console.log('dome');
};

HTML

 //divs all look like this for different inputs

 <div class="form-group">
    <label for="phone">Phone Number</label> 
    <input id="phone" ng-model="phone" 
    type="text>
</div>

提交

【问题讨论】:

  • 你所做的不是 Angular。此外,完全脱离 jQuery 设计可能是它不起作用的一个原因。尝试使用 ngModel 和 ngClick 正确执行此操作。如果您关心您的应用程序,请删除 jQuery。
  • 角码在哪里?它不是角形。
  • @MohaiminMoin,我更新了,让我知道你的想法!谢谢'
  • 将代码改为firebaseRef.push({Title: $scope.title, Description: $scope.moreinfo, Email: $scope.email, Number: $scope.number, Date: $scope.rtime}); 另见:firebase.com/docs/web/guide/saving-data.html#section-push

标签: javascript angularjs firebase firebase-realtime-database


【解决方案1】:

push 是一个带有签名的函数:

push() - push([value], [onComplete])
Generates a new child location using a unique key and returns a Firebase reference to it.

请参阅此处的文档。 https://www.firebase.com/docs/web/api/firebase/push.html

使用示例

var messageListRef = new Firebase('https://SampleChat.firebaseIO-demo.com/message_list');
    messageListRef.push({ 'user_id': 'fred', 'text': 'Yabba Dabba Doo!' });
// Same effect as the previous example, but we've combined the push() and the set().

【讨论】:

    猜你喜欢
    • 2016-02-04
    • 1970-01-01
    • 1970-01-01
    • 2013-11-27
    • 1970-01-01
    • 1970-01-01
    • 2015-11-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多