Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/416.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
Javascript Http使用Angular UI网格将更改放在后端_Javascript_Angularjs_Angular Ui Grid - Fatal编程技术网

Javascript Http使用Angular UI网格将更改放在后端

Javascript Http使用Angular UI网格将更改放在后端,javascript,angularjs,angular-ui-grid,Javascript,Angularjs,Angular Ui Grid,我是angularJS的新手,我正在使用AngularUI-grid可编辑功能,并且能够在UI端编辑它,但编辑的值不会进入后端/API 请看下面的plunker。我能够编辑并建议使用ui网格将可编辑数据发送到API的 我认为需要实现更改以将可编辑数据发送到API的代码 $scope.gridOptions.onRegisterApi = function(gridApi) { //set gridApi on scope $scope.gridApi = gridApi; grid

我是angularJS的新手,我正在使用AngularUI-grid可编辑功能,并且能够在UI端编辑它,但编辑的值不会进入后端/API

请看下面的plunker。我能够编辑并建议使用ui网格将可编辑数据发送到API的

我认为需要实现更改以将可编辑数据发送到API的代码

$scope.gridOptions.onRegisterApi = function(gridApi) {
  //set gridApi on scope
  $scope.gridApi = gridApi;
  gridApi.edit.on.afterCellEdit($scope, function(rowEntity, colDef, newValue, oldValue) {
    //Do your REST call here via $hhtp.get or $http.post
    //This alert just shows which info about the edit is available
    alert('Column: ' + colDef.name + ' ID: ' + rowEntity.id + ' Name: ' + rowEntity.name + ' Age: ' + rowEntity.age)
  });
};

我有类似的东西。我的后端使用ASP.NET Web API。基本上,我创建一个json对象,将其字符串化并将其传递给post。然后在web API中更新数据存储

var data = JSON.stringify({ Key: keyValue, Column: col.field, Value: newValue });

$http.post("api/Account/UpdateData", data)
            .then(function (response) {
            }, function (error, status) {
            });

您需要有一个调用的API来更新服务器上的值。您是否已经设置了web API?是的,我的项目中已经设置了API。但首先我在plnkr上练习如何在主项目实施之前完成它。它将不完全相同。您可以使用$http.get来读取json文件,但您将无法使用$http.post来更新plunker中的值,我不认为。从plunker获取数据,然后将其存储在本地并仅在本地更新阵列的示例。您不能在plunker上执行$http.post,因此在那里编辑它有点毫无意义。您需要自己编写的web api才能使其正常工作。