我偶然发现了这个npm包,它根据我们的需求对数组进行分组。我需要在我的angular应用程序中使用这个包来分组我的数组。我应该如何将这些包导入到我的angular应用程序中。是否有其他模块存在于组数组中。https://www.npmjs.com/package/group-array#examples
发布于 2019-04-09 09:41:52
发布于 2019-04-09 09:51:13
从'rxjs‘导入{ Observable}
由于类型跟随,ES6导入的syntex将在此处工作
发布于 2019-04-09 09:52:02
如果你使用的是typescript,那么
import * as ga from "../../../../../node_modules/group-array"; //proper path to your node_modules/group-array
arr = [
{tag: 'one', content: 'A'},
{tag: 'one', content: 'B'},
{tag: 'two', content: 'C'},
{tag: 'two', content: 'D'},
{tag: 'three', content: 'E'},
{tag: 'three', content: 'F'}
];
ngOnInit() {
console.log(ga(this.arr, 'tag'));
}
https://stackoverflow.com/questions/55589384
复制