AngularFire&安培;离子 - 无数据形式发送到服务器 [英] AngularFire & Ionic - No data form is transmitted to server
本文介绍了AngularFire&安培;离子 - 无数据形式发送到服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用液碱中和AngularFire为使我的应用程序,但我有一个(新的)的问题:
我的数据表是空的!我们可以看到,只是在我的数据库火力地堡的fiels。
我该怎么做来检索用户在火力地堡数据库中输入的表单数据?
I use Ionic and AngularFire for make my app, but I have a (new) problem: My data form are empty ! We can see just the fiels in my DataBase Firebase. How do I do to retrieve the form data entered by the user in the Firebase database?
在形象问题:
http://img15.hostingpics.net/pics/238594event.png
这是我的HTML:
<form ng-submit="submitEvent(event)">
<label class="item item-input item-stacked-label">
<span class="input-label"><i class="fa fa-pencil"></i> Nom de l'événement</span>
<input type="text" ng-model="event.nameid">
</label>
<label class="item item-input item-stacked-label">
<span class="input-label"><i class="icon ion-ios-information"></i> Description</span>
<br><textarea ng-model="event.descriptionid"></textarea>
</label>
<label class="item item-input item-stacked-label">
<span class="input-label"><i class="fa fa-location-arrow"></i> Adresse</span>
<input type="text" ng-model="event.addressid">
</label>
<button class="button" type="submit" value="Add Event" id="success-btn-create"><i class="fa fa-arrow-right"></i></button></form>
这是我的控制器JS:
myApp.controller('Step1Ctrl', ['$scope', 'Event', 'Auth', '$rootScope', '$state', '$firebaseArray', function($scope, Event, Auth, $rootScope, $state, $firebaseArray) {
$scope.submitEvent = function(event) {
var nameid = $scope.nameid;
var eventRef = new Firebase("https://myApp.firebaseio.com/Events");
eventRef.push($scope.event);
$scope.event = {nameid: '', descriptionid: '', adressid: ''};
}
$scope.deleteEvent = function(index) {
$scope.events.splice(index , 1);
}
}])
这是我的服务JS:
myApp.factory("Event", ["$firebaseArray", function($firebaseArray) {
var eventRef = new Firebase('https://myApp.firebaseio.com/Events/');
return $firebaseArray(eventRef);
}]);
这是可选的问题:如何恢复组织者的名字吗?他记录与Facebook ...
An optional question : How to recover a name of the organizer ? He is logged with Facebook ...
感谢所有乡亲!
推荐答案
添加到您的控制器:
$scope.submitEvent = function(event) {
Event.add(event).then(function (data){
$scope.event = {nameid: null, descriptionid: null, adressid: null};
});
}
您还可以重新组织你的服务如下:
you can also reorganize your service as follows:
myApp.factory("Event", ["$firebaseArray", function($firebaseArray) {
var eventRef = new Firebase('https://myApp.firebaseio.com/Events/');
return {
get: function (){
return $firebaseArray(eventRef);
}
,
add: function (event){
var eventInfo = $firebaseArray(eventRef);
return eventInfo.$add(event);
}
}
}]);
希望这有助于!
这篇关于AngularFire&安培;离子 - 无数据形式发送到服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文