【问题标题】:AngularJS CheckItems selected Items to Delete as HTTP RequestAngularJS CheckItems 选择要删除的项目作为 HTTP 请求
【发布时间】:2015-11-29 20:09:23
【问题描述】:

我想使用一个按钮点击,所以当这个按钮被点击时

<button type="button" ng-click="delete()">Delete</button>

要使用这个功能,

$scope.delete = function() {    


for( i=0; <each selected Item , i++) 

我不知道如何编码 Javascript,但可以说使用复选框选择了 10 个项目 我想让 10 个 Http 删除请求作为选择的参数 ID 需要作为 Rest Service 的参数。用户名和密码保存在其他地方。

$http.get("https://localhost/delete?username=" + $scope.email1 + "&password=" + $scope.password1 +&scope.selectedItemID).success(function(response)
}
    })  

这是 Html 文件:

<tr ng-repeat="Object in ObjectList track by $index">
        <td>
            <input type="checkbox" ng-model="Object.isCheck" ng-change="checkChange(Object)"/>
        </td>   
                            <td>{{ Object.idObject}}</td>
                            <td>{{ Object.messageObject }}</td>         
                        </tr>
                    </tbody>
                </table>            
</div>

【问题讨论】:

    标签: angularjs rest checkbox


    【解决方案1】:

    试试这个删除功能:

    $scope.delete = function () {
        $scope.objectList.forEach(function (object) {
            if (object.isCheck) {
               // here you can do with the checked object what you want
            }
        })
    };
    

    在我留下评论的地方,你只需要像你一样调用$http 服务。您可以访问完整的对象,因此您也应该能够访问对象 ID。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-24
      • 1970-01-01
      相关资源
      最近更新 更多