With a normal single page razor component in Blazor. I can inject IJSRuntime like this at the top of the page:
@inject IJSRuntime JSRuntime
If I create a code behind .razor.cs file for the component, how do I inject something like IJSRuntime into the code behind file?
In the code behind razor.cs file, IJSRunTime or others can be injected with the [Inject] attribute
public partial class BillingDashboard
{
[Inject]
IJSRuntime JSRuntime { get; set; }
protected override async Task MyFunction()
{
await JSRuntime.InvokeVoidAsync("console.log('test')");
}
}