0
anglejを使用してfirebaseデータベースによってデータをプッシュしようとしています。私はシステムを鍵として使用し、次に機器を子供として使用しましたが、データをプッシュするとキーを生成し、機器を保管します。私はそれはそうのような私のデータを格納したい:子クラスは、firebaseデータベースにデータをプッシュするときにidを自動的に生成します。
System -> Equipment1
-> Equipment2
-> Equipment3
System2 -> Equipment1
-> Equipment2
-> Equipment3
は、ここに私のコードです:
/*global angular*/
var app = angular.module('input', ['ngRoute', 'firebase']);
app.config(['$routeProvider', function ($routeProvider) {
'use strict';
$routeProvider.when('/input', {
templateUrl: 'input/input.html',
controller: 'inputCtrl'
});
}]);
app.controller('inputCtrl', ['$scope', '$firebaseObject', function ($scope, $firebaseObject) {
'use strict';
$scope.system;
$scope.message;
$scope.writeUserData = function (equipment) {
firebase.database().ref('data/' + $scope.system + '/equipments').push({
equipment: equipment
});
$scope.message = "Success";
}
}]);
これは、それは私がデータをプッシュした後、次のようになります。