我有一個回調函數以下濾鏡陣列:獲取指數
array.filter(createPredicateFn(expression, comparator));
我的回調函數聲明如下:
function createPredicateFn(expression, comparator) {
我怎樣才能得到我的createPredicateFn中的元素的索引?
編輯:
這裏是我的預測函數:
function createPredicateFn(expression, comparator) {
var predicateFn;
if (comparator === true) {
comparator = angular.equals;
} else if (!angular.isFunction(comparator)) {
comparator = function (actual, expected) {
if (angular.isObject(actual) || angular.isObject(expected)) {
// Prevent an object to be considered equal to a string like `'[object'`
return false;
}
actual = angular.lowercase('' + actual);
expected = angular.lowercase('' + expected);
return actual.indexOf(expected) !== -1;
};
}
predicateFn = function (item) {
return deepCompare(item, expression, comparator);
};
}
顯示完整的代碼 – 2014-12-05 15:05:16
我們不能幫你沒有爲你的'createPredicateFn' – drinchev 2014-12-05 15:05:35