首页 > 解决方案 > 编辑表格中的单元格保存到 django 模型

问题描述

我有一张员工表。我正在使用 $http 加载数据并使用 ng-repeat 将其打印在网页上。我想编辑每一行的内容。HTML:

tbody ng-repeat="list in data" >
                    <tr ng-hide="edit" ng-click="edit=true">

                            {% verbatim %}
                            <td> {{$index + 1}}</td>
                            <td>{{ list.associate_nbr }}</td>
                            <td>{{ list.per }}%</td>
                            <td>{{ list.count }}</td>
                            <td>{{ list.sample_per }}%</td>
                            <td>{{ list.sample}}</td>
                            <td><input type="text" value="{{ list.focused 
                             }}"></td>
                            <td><input type="text" value="{{ 
                            list.random_field }}"></td>

                </tr>
                {% endverbatim %}

主.JS

(function(){
    'use strict';
     angular.module('sampling.demo',[])
     .controller('SamplingController', ['$scope','$http',SamplingController]);
     function SamplingController($scope,$http)
     {

        $scope.data = [];
        $http.get('/sample/').then(function(response){

        $scope.data = response.data;
        });

     }
}());

当用户单击它时,我想编辑最后两个字段。

标签: djangoangulardjango-modelsdjango-rest-framework

解决方案


推荐阅读