I am creating a custom function in a service file where I am trying to limit the string length. But I don't know how to call that function from angular view component.
generalservice.ts
-----------------------
export class GeneralService {
constructor() { }
removeHTML(str:any){
var tmp = document.createElement("DIV");
tmp.innerHTML = str;
return tmp.textContent || tmp.innerText || "";
}
}
app.component.ts
--------------------
doSomething(){
subscribe(data => {
this.allBlogs = data.blogs.data;
}
);
}
app.component.html
----------------------
<div class="post-item border" *ngFor="let blogs of allBlogs">
{{ removeHTML(blogs.heading) }}
/div>