Angular JS-Storing the row wise table values into the database

时间:2017-11-13 06:12:39

标签: html angularjs jsp angularjs-directive angularjs-scope

I have this situation: I need to bring-up a table structure into a HTML page.One of the columns in this table has to be brought from a table stored in the database.This column value along with two check boxes values needs to be stored in a database and next time these stored values should be brought in ,next time we open that page

HTML code:

   <label class="col-md-3" for="Documents">Test:</label>
           <div class="col-md-8"  ng-controller="checklistController" ng-init='populateChecklist()'>
               <div class="table-responsive">
                    <table class="table table-bordered">
                    <thead>
                      <tr>
                        <th>Name</th>
                        <th>Not Required</th>
                        <th>Completed</th>
                        <th>Link</th>
                      </tr>
                    </thead>
                      <tbody>
                       <tr ng-repeat = "x in list">
                      <td>{{x.name}}</td>
                        <td><input type="checkbox" ng-model='notRequiredCheckList'  ng-disabled="completedCheckList" ng-disabled="linkForCheckList"/></td>
                        <td><input type="checkbox" ng-disabled="notRequiredCheckList" ng-model="completedCheckList" /></td>
                        <td><input type="text" ng-model="linkForCheckList" size="30" ng-disabled="notRequiredCheckList"/></td>
                       </tr>
                      </tbody>
                  </table>
                    <button ng-click="Save()">Save</button>
              </div>
          <div>

Javascript code:

app.controller("checklistController",function($scope,$http){
        $scope.populateChecklist =  function(a){
                $http.get("commonAppGet.jsp?sqlStr=select name from test where val="+a+").then(function(resp){
                $scope.list = resp.data;
                });
        }
            });

Here I am getting name from a table and populating the first column when the page is getting loaded.Now along with these names ,I have two checkboxes along with a text box.I have added few validations.Now my challenge is,how to store these values row wise into a new table in the database and load these stored values next time.

Could someone help me?

0 个答案:

没有答案