javascript - How to read data from a table and form an array and post it? -


i want data , display on table modify "availability" , again post server forming array of object. right way doing able data not coming modification .

<!doctype html> <html>    <head>     <link rel="stylesheet" href="style.css">     <script src="script.js"></script>     <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"></script>   </head>     <body ng-app="valueexample" ng-controller="examplecontroller">       <script>    angular.module('valueexample', [])      .controller('examplecontroller', ['$scope', function($scope) {       $scope.routedetails =        [          {             "employee":"employee 1",             "date":"2016-09-25",             "availablity":"yes"          },          {             "employee":"employee 2",             "date":"2016-09-25",             "availablity":"no"          },          {             "employee":"employee 3",             "date":"2016-09-25",             "availablity":"yes"          },          {             "employee":"employee 4",             "date":"2016-09-25",             "availablity":"no"          }       ]     $scope.submit = function(data) {        console.log(data);     };       }]); </script>             <form>                   <table class="table_role" >                         <thead>                             <tr><th>employee name</th>                                 <!-- <th>date</th> -->                                 <th>availablity</th>                             </tr>                         </thead>                         <tbody ng-repeat="routedetail in routedetails | orderby">                         <tr>                             <td>{{routedetail.employee}}</td>                              <!-- <td>{{routedetail.date}}</td> -->                              <td>                                 <input type="checkbox" ng-checked="routedetail.availablity == 'yes'" />                             </td>                         </tr>                         </tbody>                     </table>                     <button ng-click="submit(routedetails)" type="submit">submit</button>             </form>   </body>   </html> 

change checkbox logic this

<td>     <input type="checkbox" ng-model="routedetail.availablity"                    ng-true-value="'yes'" ng-false-value="'no'"/> </td> 

it should work.


Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -