Search code examples
angularcordovacordova-pluginscordova-android

Load Images in Angular + Cordova App


I got my Angular 5 app working with Cordova. The only problem is the images are not loading. The path I'm specifying looks like this:

/assets/img/logo.png

I use these paths for images:

<img class="logo-img" src="/assets/img/logo.png">

as well as inside the styles:

background: url(/assets/img/success-backg.png) no-repeat center center;

This is occurring for Android and iOS builds.

Any suggestions?


Solution

  • I fixed this by replacing '/assets/..'. with './assets/...'. I'm facing issues with building sass files with relative paths and at the moment have to do the replacement right inside the output files (after ng build --prod). Probably Angular CLI has some option for handling this too.