How to check "no_cover" value inthumbnail[0] and replace it toasset/sss.jpg for showlistpage I try to set <img src="{{item.LINKS.thumbnail[0]}}"> in Listpage.html ,this show onlythumbnail[0] is http://xxx.jpg, http://xxx.jpg , ,But I have no idea to set "no_cover"
<ion-list>
<ion-item *ngFor="let item of foundRepos">
<ion-thumbnail item-left >
<img src="{{item.LINKS.thumbnail[0]}}"> <!--I have no idea to set it -->
</ion-thumbnail>
</ion-list>
The “span” elements (or any other you would like to use) are required for the ngSwitch to be executed. But “span” do normally not interfer with any layout settings even if it blows up markup.
Use the same logic to decide with templates to use for rendering based on content type.
Just do a console.log of your item element and I am pretty sure you will not get a valid object in return. After re-formating you should be able to access the desired value by item.LINKS[0].thumbnail.
Our just let your json validate e.g. by http://json.parser.online.fr/ and see if there is a valid output. Gives you also hints about expected brackets etc.
Ok, well, use item.thumbnail to compare in [ngSwitch]. If ‘no_cover’, than use the fallback image, if not, use the regular image.
To debug your while loop and ngSwitch, just log the item to the console and have a look, what’s inside. This way you should be able to adjust your switch statement or the generation of the item object.
The ngSwitchCase thing is still the way to achieve the desired solutíon.