我进行如下比较:
var searchValue = 'Apple'
var searchValue2 = 'Orange'
var index = $scope.sEntitiesListTest.findIndex(x => x.ItemText === searchValue);
我可以比较多个值,例如var index = $ scope.sEntitiesListTest.findIndex(x => x.ItemText === searchValue && x => x.ItemValue = searchValue2); ?
您在第二个比较中没有箭头功能(=>
)。另外,您错误地使用赋值运算符(=
)而不是同情操作(==
或===
):
var EntitiesListTest = [{ItemText: "Test Text", ItemValue: "Test Value"},{ItemText: "Test Text2", ItemValue: "Test Value2"}]
var searchValue = 'Test Text2';
var searchValue2 = 'Test Value2'
var index = EntitiesListTest.findIndex(x => x.ItemText === searchValue && x.ItemValue == searchValue2);
console.log(index);