I want to crate some methods and call them from html of different components. On the other hand, there is some approach as on How to call static method of other class in .html (not in .ts)?, but it is old and I am wondering if there is a better way in Angular 9 to call the method directly. Also it is possible to use a shared service and define shared method in this service, but I am looking another approach to call static methods directly from html. How can I do that?
demoBase.ts:
export class DemoBase {
static demoMethod(id) {
//
}
}
Then I want to call this method from html of another component:
list.component.ts:
import { DemoBase } from '@pages/demoBase';
//other stuff (I do not want to create a method here to access base method)
list.component.html:
<div><span [ngClass]="DemoBase.demoMethod(record.Id)">{{record.Name}}</span></div>