I'm new to angular 4.x I want to load change.js into the ngOnInit () function. How can I do this, I tried a little, but no one worked:
here is my code:
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;
});
console.log(this.data[0]);
}, 500);
});
}
....
....
....
}
You can help?
source
share