I have a razor class library with all my components. I have a class file in the library which i need to inject a service into.
I know i can do it by passing the services in the constructor but I cannot do that.
So I want to know how I can inject a service in a class file with the [Inject] .
I tried inheriting the component class like below but dint work
public class BaseComponent : Component1
{
[Inject]
public IServerProvider ServerProvider { get; set; }
public void Test()
{
var server=ServerProvider.Server; // the serverprovider is null here
//Note:I cannot use the constructor approrach to load
}
}