Reputation: 1787
I am a beginner in Angular2. I'd like to use a function from a 3rd party library, but I get "xxx is not a function".
This is the code in 'app.component.ts':
import { Component, OnInit } from '@angular/core';
import { arrayShuffle } from "array-shuffle";
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent implements OnInit {
name = 'Angular';
list: string[] = [];
ngOnInit() {
this.list.push("C value");
this.list.push("B value");
this.list.push("A value");
console.log("list: " + this.list);
const shuffled = arrayShuffle(this.list);
console.log("list: " + this.list);
}
}
This is the whole thing on stackblitz
What is my mistake?
Upvotes: 0
Views: 148
Reputation: 514
change your import line from
import { arrayShuffle } from "array-shuffle";
to
import arrayShuffle from "array-shuffle";
Upvotes: 2