Ref : https://angular.io/docs/js/latest/api/common/SlicePipe-class.html. Trying to slice first 20 characters of a string object.
Tried :
<p>{{item.description | slice:0:20}}...</p>
and
<p>{{item.description}}[0:20]: '{{item.description | slice:0:20}}'</p>
Here item.description is of type String
export class Details {
description: string;
}
@Component({
selector: 'editor'
})
export class AppComponent implements OnInit {
item: details = <Details>{};
}
Note : I am getting value for description in my template using {{item.description}}
but when i slice it says
Invalid argument 'undefined' for pipe 'SlicePipe'
Any help would be great.
This seems to be a known issue https://github.com/angular/angular/pull/7152
It seems to have been fixed recently but not yet shipped.