javascript - "See more text" in AngularPrimeNg - Stack Overflow

Please guide me achieve "see more text" functionality.I work on angular 4 and primgNg. My pag

Please guide me achieve "see more text" functionality.

I work on angular 4 and primgNg. My page shows a column named "Description". Initially I have to show only 1000 characters in the that column and show a down arrow, if the description is more than 1000 characters. On click of the down arrow the para will expand and it will show full text and the arrow turns to the up arrow. In other words, toggling. Please guide me achieve this. So far I tried as below but unable to achieve the requirement.

HTML

<div>Description</div>
<div>{{details.desc | slice:0:1000}}</div>
<div *ngIf="details.desc.length >= 1000">
  <span class="arrow-down"></span>
</div>

CSS

.arrow-down {
  width: 0; 
  height: 0; 
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;

  border-top: 10px solid #f00;
}

Please guide me achieve "see more text" functionality.

I work on angular 4 and primgNg. My page shows a column named "Description". Initially I have to show only 1000 characters in the that column and show a down arrow, if the description is more than 1000 characters. On click of the down arrow the para will expand and it will show full text and the arrow turns to the up arrow. In other words, toggling. Please guide me achieve this. So far I tried as below but unable to achieve the requirement.

HTML

<div>Description</div>
<div>{{details.desc | slice:0:1000}}</div>
<div *ngIf="details.desc.length >= 1000">
  <span class="arrow-down"></span>
</div>

CSS

.arrow-down {
  width: 0; 
  height: 0; 
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;

  border-top: 10px solid #f00;
}
Share Improve this question asked Sep 11, 2018 at 11:13 AnnaAnna 1,7098 gold badges40 silver badges68 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

I just created working example based on your code here on StackBlitz.

but better solution is to make it as directive and reuse.

hope it help.

seeMore is a boolean.

<span>
   {{
     seeMore
     ? project.descriptions
     : project.descriptions.slice(0, -5)
   }}
</span>
<span *ngIf="project.descriptions.length > 5"
      (click)="seeMore = !seeMore">
   {{ !seeMore ? "See More" : "See Less" }}
</span>

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745123282a4612541.html

相关推荐

  • javascript - &quot;See more text&quot; in AngularPrimeNg - Stack Overflow

    Please guide me achieve "see more text" functionality.I work on angular 4 and primgNg. My pag

    3小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信