I just started using angular 4.x and I'm trying to load change.js in the ngOnInit() function. I've attempted a few things but nothing seems to be working. Here is the code snippet:
This is the code I have so far:
import { Component, OnInit, Input } from '@angular/core';
...
.....
declare var chance: any;
import 'src/assets/js/chance.js';
....
....
export class ComposantComponent implements OnInit {
....
....
ngOnInit() {
this.http.get("src/app/datas/data.json")
.subscribe((data)=> {
setTimeout(()=> {
this.data = data.json();
this.data.forEach(function(row, index) {
row.checked = false;
// use chance here ...
});
console.log(this.data[0]);
// console.log(chance);
}, 500);
});
}
....
....
....
}
Any help would be greatly appreciated. Thank you.