[英]Angular function calling inside table
I want to use ajax delete function: 我想使用ajax删除功能:
angular_app.controller('contacts_controller', ['$scope', '$http', '$templateCache',
function ($scope, $http, $templateCache) {
$scope.delete(id) {
alert('del: '+id);
};
//....
}
]);
..and an assist function ..和辅助功能
function deleteContact(id) {
angular.element(document.getElementById("contacts_controller")).scope().delete(id);
}
And angular table to calling delete (I use laravel, so {[{
and }]}
instead of {{
and }}
). 和角度表来调用delete(我使用laravel,所以{[{
和}]}
而不是{{
和}}
)。
<tr ng-repeat="x in data">
<td>{[{ x.id }]}</td>
<td>{[{ x.name }]}</td>
<td>
<button onClick="deleteContact({[{ x.id }]})">Delete</a>
</td>
</tr>
How to put to work the delete contact. 如何处理删除的联系人。 onClick="deleteContact(3)"
works well. onClick="deleteContact(3)"
效果很好。 Thank you 谢谢
使用ng-click代替onclick。
<button ng-click="delete(x.id)">Delete</a>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.