【问题标题】:AngularJS - Submit items selected from listAngularJS - 提交从列表中选择的项目
【发布时间】:2016-03-26 07:28:31
【问题描述】:

如果选中复选框并单击提交按钮将数据插入数据库,我想要。

<tbody>
  <tr ng-repeat="item in rows | filter:search">
    <td>{{ite m.isbn}}</td>
    <td>{{item.kitap_ismi}}</td>
    <td>{{item.sayfa_sayisi}}</td>
    <td>{{item.baski_yili}}</td>
    <td>{{item.isim}}</td>
    <td>{{item.kategori_isim}}</td>
    <td>{{item.yayinevi_isim}}</td>                     
    <td><center><input type="checkbox"></center></td>
  </tr>
</tbody>                        

<input type="submit" name="submit" value="Submit" class="btn btn-success">

【问题讨论】:

标签: angularjs submit


【解决方案1】:

你在这里工作fiddle

我在选择的每一行都添加了“_metaSelected”属性:

<input type="checkbox", ng-model="item._metaSelected">

在提交时:

<input type="submit" name="submit" value="Submit" ng-click="submit()">

仅发送具有“_metaSelected”属性的项目:

$scope.submit = function(){
  //- Clear
  $scope.submitedRows = [];

  //- Choose selected rows
  angular.forEach($scope.rows, function(row){
    if(row._metaSelected){
      //- Remove _metaSelected property before submition
      delete row['_metaSelected'];

      $scope.submitedRows.push(row);    
    }
  });
  //- POST with submitedRows as payload
  //- yourService.save($scope.submitedRows)
}       

【讨论】:

  • 谢谢。我需要给出用户按下按钮的日期
  • 日期?你的意思是“数据”。在附加的小提琴中,我正在处理点击动作。您必须使用 POST 方法将您自己的服务放置在您的服务器上。
  • 谢谢你。很抱歉,但我不明白如何将 submitedRows 数据插入数据库
  • 我的后端是什么编程语言?
  • 我的数据库postgresql语言php
猜你喜欢
  • 2016-08-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-08-25
  • 2023-04-06
  • 2016-03-27
  • 2015-07-14
  • 1970-01-01
相关资源
最近更新 更多