I have some images and style sheets files inside assets folder in angular 2 app but how to access those files and images in main index.html file?
The Angular application has a default assets folder. By default, whatever you put in the assets folder you can access it directly from the browser and queried through an HTTP request. You can create your own folder like assets by adding that folder to the assets section in the angular. json file.
To start using the amazing File System Access API in Angular, or typescript project, you will be faced first, with unrecognized type error. Head to Typescript website and search for File System Access. The first result is the newest. @types/wicg-file-system-access.
Let's start with assets, this could be anything from images, videos, json files to styles and scripts. By default, Angular has an asset directory, located under the /src directory at the root of your angular project. This is copied over to the build directory by Angular CLI during the build process of your app.
You have to put your files and use the relative path from the assets folder.
For example if i put a css file in src/assets/css/myfile.css
, then I have to access it like this :
<link rel="stylesheet" href="assets/css/myfile.css">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With