รายการที่ต้องทำง่าย ๆ แต่มีปุ่มลบในหน้ารายการสำหรับแต่ละรายการ:
เทมเพลต HTML ที่เกี่ยวข้อง:
<tr ng-repeat="person in persons">
<td>{{person.name}} - # {{person.id}}</td>
<td>{{person.description}}</td>
<td nowrap=nowrap>
<a href="#!/edit"><i class="icon-edit"></i></a>
<button ng-click="delete(person)"><i class="icon-minus-sign"></i></button>
</td>
</tr>
วิธีการควบคุมที่เกี่ยวข้อง:
$scope.delete = function (person) {
API.DeletePerson({ id: person.id }, function (success) {
// I need some code here to pull the person from my scope.
});
};
ฉันพยายามและ$scope.persons.pull(person)
$scope.persons.remove(person)
แม้ว่าฐานข้อมูลจะถูกลบเรียบร้อยแล้วฉันไม่สามารถดึงรายการนี้ออกจากขอบเขตและฉันไม่ต้องการทำการเรียกเมธอดไปยังเซิร์ฟเวอร์สำหรับข้อมูลที่ไคลเอ็นต์มีอยู่แล้วฉันต้องการลบบุคคลนี้ออกจากขอบเขต
ความคิดใด ๆ