Angularjs lodash u.intersectionBy在回调函数中不起作用
我试图通过使用angular js typescript回调函数的“id”使用lodash intersectionBy方法,但由于某些原因,它无法使用id。如何通过id与回调函数相交 这是我的尝试Angularjs lodash u.intersectionBy在回调函数中不起作用,angularjs,typescript,lodash,Angularjs,Typescript,Lodash,我试图通过使用angular js typescript回调函数的“id”使用lodash intersectionBy方法,但由于某些原因,它无法使用id。如何通过id与回调函数相交 这是我的尝试 private filterOutputRelationFn: Function; // created declaration this.filterOutputRelationFn = _.intersectionBy; // defined console.log(this.filter
private filterOutputRelationFn: Function; // created declaration
this.filterOutputRelationFn = _.intersectionBy; // defined
console.log(this.filterOutputRelationFn([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x')); // Not working by id
Expected result:
// => [{ 'x': 1 }]
如果我尝试使用“u.intersection”也一样,它确实有效。在上述场景中会出现什么问题
private filterOutputRelationFn: Function; // created declaration
this.filterOutputRelationFn = _.intersection; // assigned
console.log(this.filterOutputRelationFn([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }])); // It works
Expected result
// => [{ 'x': 1 }]