Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How will achive content show more and show less in angular 6

We have 6 content div. And also we using character limit each div. We used bootstrap 4 angular 6 version.

6 div some toggle div content opened and some closed How to achive this case.

like image 736
Amol Avatar asked Nov 19 '18 09:11

Amol


1 Answers

It's very easy to implement with some custom css. Give this a try:

Template:

<div class="container" [class.show]="show">
    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
<button (click)="show = !show">{{ show ? 'Show less': 'Show More' }}</button>

CSS:

.container {
  font-size: 16px;
  line-height: 16px;
  height: 32px;
  overflow: hidden;
}

.show {
  overflow: visible;
  height: auto;
}

Component:

show = false;

Here's a Sample StackBlitz for your ref.

like image 175
SiddAjmera Avatar answered Oct 21 '22 15:10

SiddAjmera