I am trying to load a java script file in to a component. If the file is copied outside the 'src' folder it is working fine, but inside 'src' folder it is getting 404 error. I tried with different scenarios but issue not resolved.

Thanks
Vimal
When you serve angular application it starts the server at port 4200 with directory PROJECT_FOLDER/src that is when you load the script in component it already in the src folder so just use app/shared/... instead of src/app/shared/....
I think Angular will consider those as static files, meaning that they won't load on compile time, but rather at runtime, and at runtime there will be on /src but instead only assets (or what you ask Angular to copy over from src.
You have 2 options here:
1- Moving your static files into asstes and then you can reference them as /assets/payment/js/init-payment.js.
2- Ask Angular to copy certain directory from src into build directory when compiling.
and that's done in angular.json file inside the assets array.
For more details see this answer here: