Open etcircle opened 5 years ago
Yes, sure. Also like I sad before MatTable will have big rewriting. So, in future this problem should be resolved.
Stumble upon the same problem. Rather then require an inject through services.AddScoped I would recommend changing the component itself to support situations where http is not available. To allow this the following code adaptation should work:
Change BaseMatComponent
to use OwningComponentBase instead of ComponentBase (or similar to cover MatTable
only and not "every" component)
public abstract class BaseMatComponent : OwningComponentBase, IBaseMatComponent, IDisposable
Add to MatTable
@using Microsoft.Extensions.DependencyInjection
private System.Net.Http.HttpClient Http { get; set; }
protected override async Task OnInitializedAsync()
{
Http = ScopedServices.GetService<System.Net.Http.HttpClient>();
…
Remove from MatTable
@inject
System.Net.Http.HttpClient Http
Also the functions SearchData
and SearchPagedData
have to be adapated to reflect that http might be NULL.
Hi, thanks for the hard work. It is just a note.
Table component injects Http Client. However, on blazor server-side, it doesn't exist. you may want to add in the installation steps, adding something like: