Currently facing some difficulties getting this simple task to work...
Here is the URL format I am dealing with:
https://website.com/image{width}x{height}.jpg
My objective is to replace the {width}
and {height}
placeholders.
I attempted using this function, but it keeps throwing an error message:
placeThumb(thumb:String){
thumb = thumb.replace('{width}', '300');
thumb = thumb.replace('{height}', '150');
return thumb;
}
The error message I consistently receive is:
Uncaught (in promise): TypeError: Cannot read property 'replace' of undefined
TypeError: Cannot read property 'replace' of undefined at PlayerPage.webpackJsonp.109.PlayerPage.placeThumb (http://localhost:8100/build/main.js:202:23)
at Object.eval [as updateRenderer] (ng:///AppModule/PlayerPage.ngfactory.js:166:26)
at Object.debugUpdateRenderer [as updateRenderer] (http://localhost:8100/build/vendor.js:15109:21)
at checkAndUpdateView (http://localhost:8100/build/vendor.js:14223:14)
at callViewAction (http://localhost:8100/build/vendor.js:14569:21)
at execComponentViewsAction (http://localhost:8100/build/vendor.js:14501:13)
at checkAndUpdateView (http://localhost:8100/build/vendor.js:14224:5)
at callWithDebugContext (http://localhost:8100/build/vendor.js:15472:42)
at Object.debugCheckAndUpdateView [as checkAndUpdateView] (http://localhost:8100/build/vendor.js:15009:12)
at ViewRef_.detectChanges (http://localhost:8100/build/vendor.js:11993:22)
It seems like a straightforward issue, but there might be something I'm overlooking.
This is how the HTML appears:
<ion-card>
<img [src]="placeThumb(playerData.twitch_thumb)"/>
<ion-card-content>
<ion-card-title>
<ion-icon name="logo-twitch" class="iconblink"></ion-icon> Streaming: {{playerData.twitch_title}}
</ion-card-title>
<p>
{{ playerData.twitch_thumb }}
{{ placeThumb(playerData.twitch_thumb) }}
</p>
</ion-card-content>
</ion-card>