带有lodash$.map的jquery

带有lodash$.map的jquery,jquery,lodash,Jquery,Lodash,我想在我的代码中使用lodash 我使用了jQuery,但我想用lodash- 我的jQuery代码: $scope.annotations = $scope.dashboard.annotations.list; var indexes = $.map($scope.annotations, function(obj, index) { if(obj.name === annotation) { return index; } }); var firstInde

我想在我的代码中使用
lodash

我使用了
jQuery
,但我想用
lodash
-

我的jQuery代码:

$scope.annotations = $scope.dashboard.annotations.list;
var indexes = $.map($scope.annotations, function(obj, index) {
    if(obj.name === annotation) {
        return index;
    }
});
var firstIndex = indexes[0];
$scope.annotations.splice(firstIndex, 1);
我正在查找匹配对象的索引值。 用什么代替
$.map
我试过
.map
.filter
没有得到准确的结果。

正确吗

我的代码:

  $scope.annotations = $scope.dashboard.annotations.list;
  var index = _.findIndex($scope.annotations, function(obj) {
    return obj.name === annotation;
  });
  $scope.annotations.splice(index, 1);

这很好用。。我只是想知道逻辑是否正确。

在我看来,像是角度范围元素注释和下划线映射方法。您通常不会将jQuery与Angular混合使用,因为这被认为是一种不好的做法。在任何情况下,似乎都不清楚您想要归档什么。也许一些输入数据,以及你期望的和你得到的,可以解决这个问题。