Skip to main content
Version: v5

ion-img

Img is a tag that will lazily load an image when ever the tag is in the viewport. This is extremely useful when generating a large list as images are only loaded when they're visible. The component uses Intersection Observer internally, which is supported in most modern browser, but falls back to a setTimeout when it is not supported.

Usage

<ion-list>
<ion-item *ngFor="let item of items">
<ion-thumbnail slot="start">
<ion-img [src]="item.src"></ion-img>
</ion-thumbnail>
<ion-label>{{item.text}}</ion-label>
</ion-item>
</ion-list>

Properties

alt

DescriptionThis attribute defines the alternative text describing the image. Users will see this text displayed if the image URL is wrong, the image is not in one of the supported formats, or if the image is not yet downloaded.
Attributealt
Typestring | undefined
Defaultundefined

src

Description画像のURL。この属性は <img> 要素では必須です。
Attributesrc
Typestring | undefined
Defaultundefined

Events

NameDescription
ionErrorimgの読み込みに失敗したときに発行されます。
ionImgDidLoad画像の読み込みが終了したときに発行されます。
ionImgWillLoadimg srcが設定されたときに発行されます。

Methods

No public methods available for this component.

CSS Shadow Parts

NameDescription
image内側の img 要素。

CSS Custom Properties

No CSS custom properties available for this component.

Slots

No slots available for this component.