我自定义管道缩短字符串不起作用。我已经将它包含在我的app.module声明中,并将其导入到我的组件中。代码如下。自定义角度4管道不工作
` import { Pipe, PipeTransform } from '@angular/core';
/*
Takes a string and replaces it with a shortend version based on the length you give it if its greater than 14 char for Example
someString = "hey whats up my name is Bob and im from Bob town"
{{value | shortString : length of new string}}
{{someString | shortString: 10}}
*/
@Pipe({name: 'shortString'})
export class shortString implements PipeTransform {
transform(value: any, length: number): string {
console.log('expected new string '+value.slice(0,length)+'...');
return (value.length()>14)?value.slice(0,length)+'...': value;
}
}`
它是如何不工作的工作plunker?它是否产生错误?或者只是不缩短价值? – DeborahK