我想要獲取數組的最後一個元素的id。如何檢索Angular 2中數組的最後一個元素ID
這是我如何我的數組
let last = this.Array[this.Array.length-1];
console.log(last);
這裏的最後一個元素取是基於陣列
Object {id: 48, title: "I'm used to this"}
title: "I'm used to this"
id: 48
__proto__: Object
這裏最後一個元素的控制檯上,我已經看過already-名單
How to retrieve the clicked ElementId in angularjs?
How to get the object's id?
how to get the id name in html for any object和更多,但我不能。
我只想訪問id : 48
,任何人都可以幫助我這樣做。
在此先感謝。
怎麼樣'的console.log(last.id);'? –
它顯示了這一點 - 錯誤TS2339:'Object'類型中不存在屬性'id'。 –
看起來你的linter配置存在更多問題,或者如果你配置瞭如此嚴格的linter規則,使用具體的類和接口而不是'Object'。 –