我想使用 $ scope 将数据从输入发送到Firebase数据库。我不知道如何从$ scope向firebase数据库发送所有数据。 这是html代码:
<div ng-app="angularjs-starter" ng-controller="MainCtrl">
<table id="table_curse" class="mdl-data-table mdl-js-data-table ">
<thead>
</thead>
<tbody>
<tr data-ng-repeat="choice in choices">
<td>
<select><option value="Incarcare">Incarcare</option><option value="Descarcare">Descarcare</option></select>
</td>
<td><input type="text" ng-model="choice.Locatie" name="Locatie" placeholder="Locatie" ></td>
<td><input type="text" ng-model="choice.Nr" name="Nr" placeholder="Nr" style="width: 40px;"></td>
<td><input type="text" ng-model="choice.Greutate" name="Greutate" placeholder="Greutate"></td>
<td><input type="text" ng-model="choice.Referinta" name="Referinta" placeholder="Referinta"></td>
<td><input type="text" ng-model="choice.Observatii" name="Observatii" placeholder="Observatii"></td>
<td><button class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect remove" ng-show="$last" ng-click="removeChoice()">Sterge pas</button></td>
</tr>
</div>
</tbody>
</table>
</div>
这是动态表的javascript:
<script>
var app = angular.module('angularjs-starter', []);
app.controller('MainCtrl', function($scope) {
$scope.choices = [{id: 'pas1'}];
$scope.addNewChoice = function() {
var newItemNo = $scope.choices.length+1;
$scope.choices.push({'id':'pas'+newItemNo});
};
$scope.removeChoice = function() {
var lastItem = $scope.choices.length-1;
$scope.choices.splice(lastItem);
};
});
</script>