1

I came across this npm package which groups array according to our requirement. I need to use this package in my angular application to group my array. How should I import these package to my angular application. Is there are any other module present to group array. https://www.npmjs.com/package/group-array#examples

David
  • 5,882
  • 3
  • 33
  • 44
JarvisEd
  • 11
  • 2
  • did you find any of these answers helpful? https://stackoverflow.com/questions/43247333/group-an-array-of-objects-in-angularjs – Anas AL-zghoul Apr 09 '19 at 09:35

4 Answers4

0

You should use import it using ES6 syntax example:

import groupArray from 'group-array';

Here is stackblitz demo

This is exactly the syntax used to import angular modules

alt255
  • 3,396
  • 2
  • 14
  • 20
0

import { Observable} from 'rxjs'

as type follow syntex of ES6 import will work here

Aakash Handa
  • 1,215
  • 11
  • 18
0

If you are using typescript then

  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'));
  }
-2

Can you plz try this once, install it first using npm

npm install group-array

import * as groupArray from 'group-array'