简体   繁体   中英

Angular function calling inside table

I want to use ajax delete function:

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 }} ).

<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. Thank you

使用ng-click代替onclick。

 <button ng-click="delete(x.id)">Delete</a>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM