I am trying to read a list of files from a local directory using Angular 5-.
However i get the following error:
TypeError: fs.readdir is not a function
My .ts file is below:
import { Component, OnInit } from '@angular/core';
import * as fs from 'fs';
@Component({
selector: 'app-review',
templateUrl: './review.component.html',
styleUrls: ['./review.component.css']
})
export class ReviewComponent implements OnInit {
constructor() { }
ngOnInit() {
var fs = require('fs');
fs.readdir('./assets', function (err, files) {
// "files" is an Array with files names
console.log(files);
});
}
}
Note have done npm install fs --save.
Also please help me finding datemodified info of the files.