toogle text more\less

Downloads in past


331.0.06 years ago6 years agoMinified + gzip package size for ngx-read-more in KB


Read More(toogle text) directive for angular2

This is a simple toogle text directive for angular2

At first step you need mark your text-div and get him id like "read-more" if in you need use it with ngFor - "read-more{{i}}"
import { Component } from '@angular/core';
@Component({ selector: 'app-root', template: `
<p #textContent id="read-more">  
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Provident reiciendis voluptate
<div class="read-more-link">
<a readMore [readMore-length]="430" [readMore-element]="textContent">
<span class="less">Less <i class="fa fa-angle-right" aria-hidden="true"></i></span>
<span class="more">More <i class="fa fa-angle-right" aria-hidden="true"></i></span>
`, styleUrls: './app.component.css' }) export class AppComponent { title = 'app works!'; }
Then create your button event element
  1. Add attribute "read more"
  1. Set length of text that we need show by default
  1. Set element that we need cut
  1. Here is your buttons less and more u can inset whetewer but there are must be 2 elements with classes ".more" and ".less"