我正在创建一个有角度的应用程序,并且有带有复选框的项目。当用户单击复选框时,我会将选中的项目记录到对象中。该对象看起来像这样:
{1: false, 7: true, 8: true};
Run Code Online (Sandbox Code Playgroud)
When a user clicks on the delete button I need to get only selected items ids.
So I need to filter objects by values and as a result, get an array of integers.
I tried the following code with the lodash library:
console.log(_.pick(this.selectedItems, _.identity));
return _.pick(this.selectedItems, function (value, key) {
return value;
});
Run Code Online (Sandbox Code Playgroud)
But this returns an empty array.
What I need to get is an array [7,8]
What is wrong with my …