如何使用angularJS

时间:2016-05-23 01:25:24

标签: javascript python html angularjs django

我的目标是在用户点击添加按钮后在我的表格中创建一个新的tr。以下是我的html& angularcode:

HTML:

<tr>
                    <td contenteditable='true' ng-model="item"></td>
                    <td>
                        {%verbatim%}
                        <select ng-model="s_value" class="form-control">
                          <option value="">--Select--</option>
                          <option ng-repeat="s in sev_list">
                            {{ s.rank}}-{{s.specific_value }}</option>
                        </select>
                        {%endverbatim%}
                    </td>
                    <td>
                        {%verbatim%}
                            <select ng-model="o_value" class="form-control">
                                <option value="">--Select--</option>
                                <option ng-repeat="o in occ_list" ng-value="s.rank" >{{o.rank}}-{{o.specific_value}}</option>
                         {%endverbatim%}
                            </select>
                    </td>
                    <td contenteditable='true' ng-model="control"></td>
                    <td>
                        {%verbatim%}
                            <select ng-model="d_value" class="form-control">
                                <option value="">--Select--</option>
                                <option ng-repeat="d in det_list" ng-value="s.rank" >{{d.rank}}-{{d.specific_value}}</option>
                         {%endverbatim%}
                            </select>
                    </td>
                    <td style="background-color: yellow;" ng-model="rpn"></td>
                    <td contenteditable='true' ng-model="r_action"></td>
                    <td>
                        {%verbatim%}
                        <select ng-model="s_new" class="form-control">
                          <option value="">--Select--</option>
                          <option ng-repeat="s in sev_list">
                            {{ s.rank}}-{{s.specific_value }}</option>
                        </select>
                        {%endverbatim%}
                    </td>
                    <td>
                        {%verbatim%}
                            <select ng-model="o_new" class="form-control">
                                <<option value="">--Select--</option>
                                <option ng-repeat="o in occ_list" ng-value="s.rank" >{{o.rank}}-{{o.specific_value}}</option>
                         {%endverbatim%}
                            </select>
                    </td>
                    <td>
                        {%verbatim%}
                            <select ng-model="d_new" class="form-control">
                                <option value="">--Select--</option>
                                <option ng-repeat="d in det_list" ng-value="s.rank" >{{d.rank}}-{{d.specific_value}}</option>
                         {%endverbatim%}
                            </select>
                    </td>
                    <td style="background-color: yellow;" ng-model="rpn_new"></td>
                    <td width="1px" style="border-style: hidden;">
                        <button class="btn btn-success btn-xs">
                            <span class="glyphicon glyphicon-plus"></span></button><br/><br/>
                        <button class="btn btn-danger btn-xs">
                            <span class="glyphicon glyphicon-minus"></span></button>
                    </td>
                </tr>

ANGULAR:

$scope.addFm = function() {
            $scope.fm = {};
            $scope.final_data.checks.push($scope.fm);
        };


        $scope.final_data = {user:$scope.user};

        $scope.submit = function () {
            data = {};
            angular.extend(data, $scope.final_data);
            angular.extend(data, { fms : $scope.final_data.fms });
            $http.post('{% url 'createfm_submit'  %}', data).success(function(data){
                $modalInstance.close();
            }).error(function(){
                alert('Internal Error Need Developer Attention.');
            });
        };

结构可能是字典里面的列表?我的意思是每个项目都会在字典中创建一个列表,我们在tr中从字典中重复(k,v)?有点困惑。有人可以给我一个解决方案吗?对于angularJS来说有点新鲜。提前谢谢。

0 个答案:

没有答案