Break Line Correctly in a List with Data Binding Angularjs

Asked

Viewed 1,977 times

0

I have a list of comments where I display some data. But when the comment is too big the list gets strange because the lines break does not happen correctly.

Example: inserir a descrição da imagem aqui

Here is the code:

<div class="jumbotron">
  <div layout="row" layout-margin>
    <div flex="40">
      <p>Comentários</p>
    </div>
    <div flex="30">
      <md-button type="file" class="md-raised md-primary" style="width:100%;margin-left: 115%;margin-top: -1px;" data-toggle="modal" 
      data-target="#myModal"><i class="fa fa-files-o"></i>
        Novo Comentário</md-button>
      </div>
    </div>
  </br>
</br>
<ul class="list-group" ng-repeat="comentario in comentarios">
  <li class="list-group-item">
    <i class="fa fa-user"></i>
    <b>{{comentario.usuario.login}}</b><i class="fa fa-comment" style="margin-left: 40px;" ></i>{{comentario.comentario}}
    <i class="fa fa-calendar" style="margin-left: 50px;"></i>{{comentario.dataComentario | date: "dd-MM-yyyy HH:mm"}}</li>
  </ul>
</div>

How can I get this list?

OBS: I’m making CSS Inline for testing.

2 answers

3


  • Thank you, it worked perfectly.

1

Instead of just entering your data directly into your <i> , you could create a div, and pre-determine its size, done this could use a javascript to count the size of the texts and so when exceeding this value is inserted a tag

if(meutexto.length > 25)
{
  $('.minhalinha').append("<br>");
}

This would be an alternative to achieve this breaking of text.

  • This check is not an appropriate way to do this. Imagine if you have many comments? Screen of different resolutions?

  • Indeed, but in my view this would be the simplest form, which can be easily manipulated by media querys and some width check "ifs"

Browser other questions tagged

You are not signed in. Login or sign up in order to post.