Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 使用Angularfire和AngularXeditable更新数据字符串_Angularjs_Firebase_Angularfire - Fatal编程技术网

Angularjs 使用Angularfire和AngularXeditable更新数据字符串

Angularjs 使用Angularfire和AngularXeditable更新数据字符串,angularjs,firebase,angularfire,Angularjs,Firebase,Angularfire,我正在开发我的第一个小型AngularFire/AngularJs应用程序。我想使用插件。 到目前为止,我可以创建和保存新数据,但找不到如何使用Angular xeditable更新现有数据 我没有收到错误消息,有什么问题: HTML <table class="table table-hover" ng-controller="premiercontrolleur"> <tr><th>Prénom</th><th>Nom</th

我正在开发我的第一个小型AngularFire/AngularJs应用程序。我想使用插件。 到目前为止,我可以创建和保存新数据,但找不到如何使用Angular xeditable更新现有数据

我没有收到错误消息,有什么问题:

HTML

<table class="table table-hover" ng-controller="premiercontrolleur">
<tr><th>Prénom</th><th>Nom</th></tr>
    <tr ng-repeat="client in clients">
    <td editable-text="client.prenom" onbeforesave="saveClient($data)">{{client.prenom}}</td>
    <td editable-text="client.nom" onbeforesave="saveClient($data)">{{client.nom}}</td>
</tr>
</table>
<table class="table table-hover" ng-controller="premiercontrolleur">
<tr><th>Prénom</th><th>Nom</th></tr>
    <tr ng-repeat="client in clients">
    <td editable-text="client.prenom" onbeforesave="saveClient(client)">{{client.prenom}}</td>
    <td editable-text="client.nom" onbeforesave="saveClient(client)">{{client.nom}}</td>
</tr>
</table>
我试图理解如何在这里使用save方法:

我找到了答案

Javascript

var app = angular.module("crmfirebase", ["firebase", "xeditable"]);

app.run(function(editableOptions) {
  editableOptions.theme = 'bs3'; // bootstrap3 theme. Can be also 'bs2', 'default'
});

app.controller("premiercontrolleur", function($scope, $firebase) {
  var ref = new Firebase("https://mydatabaseurl.firebaseio.com/clients");
  var sync = $firebase(ref);

  $scope.clients = sync.$asArray();

  $scope.addClient = function(client) {
    $scope.clients.$add({prenom: client.prenom, nom: client.nom});
  }

  $scope.saveClient = function(data) {
    $scope.clients.$save({prenom: data});
  }
});
$scope.saveClient = function (client) {
  $scope.clients.$save(client);
};
HTML

<table class="table table-hover" ng-controller="premiercontrolleur">
<tr><th>Prénom</th><th>Nom</th></tr>
    <tr ng-repeat="client in clients">
    <td editable-text="client.prenom" onbeforesave="saveClient($data)">{{client.prenom}}</td>
    <td editable-text="client.nom" onbeforesave="saveClient($data)">{{client.nom}}</td>
</tr>
</table>
<table class="table table-hover" ng-controller="premiercontrolleur">
<tr><th>Prénom</th><th>Nom</th></tr>
    <tr ng-repeat="client in clients">
    <td editable-text="client.prenom" onbeforesave="saveClient(client)">{{client.prenom}}</td>
    <td editable-text="client.nom" onbeforesave="saveClient(client)">{{client.nom}}</td>
</tr>
</table>

您在$scope.clients.$save()中传递什么?它不接受随机数据,它接受记录或记录的索引(它必须已经在数组中)。我无法通过调用$save({prenom:data})来判断您希望发生什么。是的,我想执行“save”。我在这里读到了索引(),但我不知道如何使用它来保存特定的记录。