blazor service issues
i'm trying to set a variable based on data inside of my service but it's not letting me do it unless it's inside of a method
16 Replies
and currently i can't call upon the method without getting errors
so i'm not sure what to do
why not put it on
protected overried async Task OnInitializedAsync
? to set the variablewithout knowing what the errors actually are we can't suggest much
i'm unfamiliar
there you go, you can't do that
but how can i work around this
do it in a method like xyrile suggested
how would i do that
in the way that he said to
override that method and put your code in it
yea but in this page? and how would i call the method?
i tried calling the method like this
top one doesn't work
bottom one is just error
They said override on initialized
It's called automatically when the component initialises
You don't have to call it yourself, add the logic in there
Just type override and space and the available methods should show
okay
i got it
thank you
Since you are unfamiliar with some of the life cycle of a razor you can check this out https://learn.microsoft.com/en-us/aspnet/core/blazor/components/lifecycle?view=aspnetcore-8.0
ASP.NET Core Razor component lifecycle
Learn about the ASP.NET Core Razor component lifecycle and how to use lifecycle events.