<分区>
我正在尝试在 ng-repeat
中添加一个复选框,然后使用 $http
选中的值发布。
这是我的代码:
$scope.add_to_post = function(n){
console.log("name",n);
$http({
method: 'POST',
url: url,
data: $.param({
name: n,
}),
withCredentials: true,
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
})
.then(function successCallback(data) {
console.log('post');
}, function errorCallback(response) {
console.log(response);
console.log('error');
});
};
HTML:
<div >
<ul ng-repeat="x in messages" style="list-style:none;">
<li>
{{x.name}}
<input type="checkbox" ng-click="add_to_post(x.name)"/>
</li>
</ul>
<button ng-click="post()">post</button>
我想要选中一些 复选框
的选项,然后单击 post
并且 $http
调用正在运行。
我的笨蛋:http://next.plnkr.co/edit/zPu9DH0JyinlBvLh
提前感谢您的回答和帮助!