Reputation: 81
All the examples I can find show how to use it in the razor file like this:
@page "/"
@inject Blazored.LocalStorage.ILocalStorageService localStorage
I would like to move it to a Base file (code behind file) but nothing I try seems to work
I tried :
public class SomeClassBase : ComponentBase
{
[Inject]
public blazored.LocalStorage.ILocalStorageService;
but this did not work.
Any help from someone who is not going to answer with "Why do you want to do this" would be very much appreciated. Thank you.
Upvotes: 0
Views: 1139
Reputation: 45596
Did you try something like this:
[Inject]
public blazored.LocalStorage.ILocalStorageService localStorage { get; set;}
As far as I recall you should use a property rather than a field. Try it.
Upvotes: 1