Cross-browser multi-line text overflow with ellipsis appended within a fixed width and height

前端 未结 25 2768
栀梦
栀梦 2020-11-22 16:19

I made an image for this question to make it easier to understand.

Is it possible to create an ellipsis on a

with a fixed width and multiple
25条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-22 16:45

    Very simple func will do.

    Directive:

      $scope.truncateAlbumName = function (name) {
        if (name.length > 36) {
          return name.slice(0, 34) + "..";
        } else {
          return name;
        }
      };
    

    View:

    <#p>{{truncateAlbumName(album.name)}}<#/p>
    

提交回复
热议问题