【发布时间】:2017-04-04 18:26:45
【问题描述】:
我已经创建了自定义摘要管道类,它工作正常,但我想在子字符串的末尾添加一个阅读更多链接。当点击所有显示的内容时。
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({ name: 'summary' })
export class SummaryPipe implements PipeTransform {
transform(value: string, maxWords: number) {
if (value)
return value.substring(0, maxWords) +"... <a href='#' (click)='getAllText()'>Read more</a>";
}
getAllText() {
//return this.value; ?
}
}
我需要填写我知道的fucn,但我需要问什么是更有效和更真实的方式来完成这个?
【问题讨论】:
标签: angular2-pipe