我有這樣的過濾器,我已經過濾的錯誤[I] .splice不是一個函數.splice不是函數
.filter('tsFilter', function() {
return function(model, filter) {
var filtered = [];
if (model != null) {
for (var i = 0; i < model.length; i++) {
filtered[i] = model[i];
}
}
for (i = 0; i < filtered.length; i++) {
if (filtered[i].List.length == 0)
filtered[i].splice(i, 1);
}
return filtered;
};
})
爲什麼我有這樣的錯誤?如何解決?
Splice是一個可用於數組的JavaScript函數。 https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/splice 檢查過濾的數據[i] –