Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 71531

Ionic 2 data binding with function?

$
0
0

@pdr wrote:

For a list of items, depending on the value of a certain key in the item, I'd like to show different images. Is this possible in Ionic 2 through some kind of interpolation/data binding using a function?

For example:

items = [
    {thing: "abc", state: "1"},
    {thing: "xyz", state: "2"},
    .....];

and display the item list as

<ion-list>
    <ion-item *ngFor="#item of items">
        {{item.title}}
        <img src=getImage({{item.state}})>    <---- Is this possible?
    </ion-item>
</ion-list>

where getImage(state) function would return the path to the image file depending on the value of state.

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 71531

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>