Commit 317fc2f9 authored by prumde's avatar prumde

New Component


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@174390 ce508802-f39f-4f6c-b175-0d175dae99d5
parent e82d5d05
.overViewText{
display: inherit;
}
.viewMore{
color: mediumvioletred;
font-weight: 700;
}
\ No newline at end of file
<div class="overViewText" [innerHtml]="currentText"></div>
<a class="viewMore" [class.hidden]="hideToggle" (click)="toggleView()">View {{isCollapsed? 'More':'Less'}}</a>
import { Component, OnChanges, Input, ElementRef } from '@angular/core';
@Component({
selector: 'ecm-readmore',
templateUrl: './ecm-readmore.component.html',
styleUrls: ['./ecm-readmore.component.css']
})
export class EcmReadmoreComponent implements OnChanges {
@Input() text: string;
@Input() maxLength: number = 100;
currentText: string;
hideToggle: boolean = true;
public isCollapsed: boolean = true;
constructor(private elementRef: ElementRef) { }
ngOnChanges()
{
this.determineView();
}
toggleView()
{
this.isCollapsed = !this.isCollapsed;
this.determineView();
}
determineView()
{
if(this.text.length <= this.maxLength)
{
this.currentText = this.text;
this.isCollapsed = false;
this.hideToggle = true;
return;
}
this.hideToggle = false;
if(this.isCollapsed == true)
{
this.currentText = this.text.substring(0, this.maxLength) + ".....";
}
else if(this.isCollapsed == false)
{
this.currentText = this.text;
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment