Is it possible to use something similar to {{mystr | split(last) }} somehow?
I\'m hoping there is a pipe included already.
I'm not sure what last is. I'll guess that you mean you want the last set of characters from the string, if you split the string up by some separator. E.g., if the string is abc,def,ghi and the separator is , then you want ghi.
@Pipe({ name: 'splitLast' })
export class SplitLastPipe implements PipeTransform {
transform(value:string, [separator]):string {
let splits = value.split(separator);
if(splits.length > 1) {
return splits.pop();
} else {
return '';
}
}
}
{{mystr | splitLast:','}}
Plunker