html - javascript/angularjs cut string to fit in a div -


in angularjs/ionic mobile application have implemented list of messages. want modify it, if message text wider div container should cut string , adds 3 dots.

my message list looks this:

<ion-list ng-repeat="message in messages">         <ion-item can-swipe="true" class="item-icon-left item-icon-right">            <i class="icon ion-email-unread"></i>            <div class="row">             <span class="col col-50">               <h2>{{message.title}}</h2>             </span>             <span class="col col-50 content-right text-small">               {{message.datestring}}             </span>           </div>            <div class="row">             <span class="col text-small">               {{message.text}}             </span>           </div>            <i class="icon ion-chevron-right"></i>            <ion-option-button class="button-dark">             more           </ion-option-button>           <ion-option-button class="button-assertive">             delete           </ion-option-button>         </ion-item>        </ion-list> 

how can dynamically, depends on width of device/container?

you don't js.

simply use css's overflow , text-overflow properties:

div {    width: 50px;    overflow: hidden;    text-overflow: ellipsis;  }
<div>1234567890123456789012345678901234567890</div>


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -