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}}"
EXAMPLE
import { Component } from '@angular/core'; @Component({ selector: 'app-root', template: `Lorem ipsum dolor sit amet, consectetur adipisicing elit. Provident reiciendis voluptate
`, styleUrls: ['./app.component.css'] }) export class AppComponent { title = 'app works!'; }
Then create your button event element
- Add attribute "read more"
- Set length of text that we need show by default
- Set element that we need cut
- Here is your buttons less and more u can inset whetewer but there are must be 2 elements with classes ".more" and ".less"