Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ionic: How to display ion-item on multiple lines?

Tags:

THE SITUATION:

I am using Ionic to build an app.

I need to display a list of info regarding some people. To obtain that i am using the ionic list <ion-list> along with <ion-item> since the layout it offers it is exactly what i need.

The only problem is that each <ion-item> seems to be forced to stay on a single line, cutting the extra text it contains, as shown it the picture:

enter image description here

THE CODE:

<ion-list>     <ion-item class="item"> Name: <b> {{ person.name }} </b> </ion-item>     <ion-item class="item"> Email: <b> {{ person.email }} </b> </ion-item>     <ion-item class="item"> Title: <b> {{ person.title }} </b> </ion-item>     <ion-item class="item"> Bio: <b> {{ person.bio }} </b> </ion-item> </ion-list> 

PLUNKER:

Here is a plunker that recreates the situation. You can try to resize the browser, or the internal windows, and you can see how ion-item cut out the extra content.

http://plnkr.co/edit/Qx9fYRpiATK4lgj5g5Rk?p=preview

THE QUESTION:

How can i display the extra content in a <ion-item> element?
Is it possible to display the content in multiple lines?

like image 333
FrancescoMussi Avatar asked Jun 19 '15 11:06

FrancescoMussi


2 Answers

For Ionic 2 users, you can use text-wrap attribute as:

<ion-item text-wrap>   Multiline text that should wrap when it is too long to fit on one line in the item. </ion-item> 

You can also see the Utility Attributes Documentation for attributes that can be added to ion-item to transform the text.

like image 68
Amit Gupta Avatar answered Nov 10 '22 09:11

Amit Gupta


EDIT: Although marked as accepted, this answer was written for an early version of Ionic. Odds are, you'll want one of the answers below for the newer versions.

Class item-text-wrap should help you out, like this:

<ion-item class="item item-text-wrap">   bio: <b> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </b> </ion-item> 
like image 45
carpiediem Avatar answered Nov 10 '22 09:11

carpiediem