Closed MuhAssar closed 6 years ago
ok I'll try the suggested workaround (adding . or removing the slash) and report back
unfortunatly the issue still exists, I tried all the combinations:
<div class="svg" [inlineSVG]="'./assets/imgs/svg/1.svg'"></div>
<div class="svg" [inlineSVG]="'/assets/imgs/svg/2.svg'"></div>
<div class="svg" [inlineSVG]="'assets/imgs/svg/3.svg'"></div>
<div class="svg" [inlineSVG]="'./www/assets/imgs/svg/4.svg'"></div>
<div class="svg" [inlineSVG]="'/www/assets/imgs/svg/5.svg'"></div>
<div class="svg" [inlineSVG]="'www/assets/imgs/svg/6.svg'"></div>
<div class="svg" [inlineSVG]="'./assets/www/assets/imgs/svg/7.svg'"></div>
<div class="svg" [inlineSVG]="'/assets/www/assets/imgs/svg/8.svg'"></div>
<div class="svg" [inlineSVG]="'assets/www/assets/imgs/svg/9.svg'"></div>
nothings works at all, although assets/www is the root folder inside the android apk package.
as a comparison, I tried to load the svg file using an img tag:
<img src="./assets/imgs/svg/1.svg" />
<img src="/assets/imgs/svg/2.svg" />
<img src="assets/imgs/svg/3.svg" />
<img src="./www/assets/imgs/svg/4.svg" />
<img src="/www/assets/imgs/svg/5.svg" />
<img src="www/assets/imgs/svg/6.svg" />
<img src="./assets/www/assets/imgs/svg/7.svg" />
<img src="/assets/www/assets/imgs/svg/8.svg" />
<img src="assets/www/assets/imgs/svg/9.svg" />
and the first and the third loaded successfully.
yay problem solved!
I used chrome remote debug and found that the root folder is named _androidasset , so I changed the url accordingly and it worked successfully, all these three urls work:
<div class="svg" [inlineSVG]="'./android_asset/www/assets/imgs/svg/10.svg'"></div>
<div class="svg" [inlineSVG]="'/android_asset/www/assets/imgs/svg/11.svg'"></div>
<div class="svg" [inlineSVG]="'android_asset/www/assets/imgs/svg/12.svg'"></div>
Nice! Glad you figured it out.
Hi @arkon & @abuassar,
Thanks for pointing this out. So deploying to multiple platforms, would mean multiple svg icons?
<div class="svg" [inlineSVG]="'./android_asset/www/assets/imgs/svg/10.svg'" *ngIf="isAndroid"></div>
<div class="svg" [inlineSVG]="'/android_asset/www/assets/imgs/svg/11.svg'" *ngIf="isAndroid"></div>
<div class="svg" [inlineSVG]="'/android_asset/www/assets/imgs/svg/12.svg'" *ngIf="isAndroid"></div>
<div class="svg" [inlineSVG]="'./[IOSFOLDER]/www/assets/imgs/svg/10.svg'" *ngIf="isIOS"></div>
<div class="svg" [inlineSVG]="'/[IOSFOLDER]/www/assets/imgs/svg/11.svg'" *ngIf="isIOS"></div>
<div class="svg" [inlineSVG]="'/[IOSFOLDER]/www/assets/imgs/svg/12.svg'" *ngIf="isIOS"></div>
Correct?
You could probably have a function that returns the URL accordingly instead of doing it like that.
@arkon Yes, that, of course, would make sense to built into the app, but the idea is right?
when deploying my ionic app to android using cordova, the svg image doesn't show up, OTOH when using my ionic app in browser it shows so I believe it might be because the app is compiled for android usage or something.