How do I get all filenames in a folder using Typescript? It's for an angular 2 project.
To be more specific, what I'm trying to do is set the images for a bootstrap carousel using images from my photos folder. Currently I'm doing this:
private _images: Image[] = []
ngOnInit(): void {
this._images = [
{ "title": "Slide 1", "url": "../photos/carousel/gg_slide 1.jpg" },
{ "title": "Slide 2", "url": "../photos/carousel/gg_slide 2.jpg" },
{ "title": "Slide 3", "url": "../photos/carousel/gg_slide 3.jpg" },
{ "title": "Slide 4", "url": "../photos/carousel/gg_slide 4.jpg" },
{ "title": "Slide 5", "url": "../photos/carousel/gg_slide 5.jpg" }
]
}//ngOnInit
Then using the the images array in the html file like this:
<carousel>
<slide *ngFor="let img of _images">
<img src="{{img.url}}" alt="{{img.title}}">
</slide>
</carousel>
I'd like to be able to just loop through whatever files are in the photos folder and add them to the images array. That way all I have to do to update the carousel is to change the photos in the photos folder.