Is there any way to call the function defined in service from a DOM, I can call components function from DOM but how can we call service function, something like this:
@Injectable()
export class UtilsService {
constructor() {}
getSessionId() {}
}
<button name="getsession" (click)="UtilsService.getSessionId()">Get Session</button>
The scope for expressions in view bindings is limited to the the components class instance. There is no support to access statics, globals, types (enums), ... directly from the view.
To be able to refer to it in the view, it has to be accessible via the components class instance:
constructor(public utilsService:UtilsService) {}
<button name="getsession" (click)="utilsService.getSessionId()">Get Session</button>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With