我想刪除這取決於他們的ID陣列郵局(也將是selectes所需元素的複選框,它將使用ID爲刪除功能) 這裏是刪除服務打字稿
****here is the array
let postOffices = [
{postOfficeID: 15, postCode: '3006', postOfficeNameFR: 'TunisPost', assignedAgentFirstName: 'BEN JEMAA', assignedAgentName: 'Radhia', assignedAgentLogin: 'POABR'},
{postOfficeID: 16, postCode: '2086', postOfficeNameFR: 'SoussePost', assignedAgentFirstName: 'SAMTI', assignedAgentName: 'Achref', assignedAgentLogin: 'POASA'}
];
***here is the delete service that I tried to create
deletePostOffice(postOffice:PostOffice)
{
this.postOffices.splice(this.postOffices.indexOf(this.postOffice.postOfficeID),1);
}
您需要閱讀的indexOf(的資料),意識到這不是你應該使用的方法,然後找到了另一種方法,會做你想做的,並閱讀findIndex()的文檔。 HTTPS://developer.mozilla。org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex –