conficient/BlazorTemplater

Injecting NavigationManager

Closed this issue · 1 comments

Hi,

Trying to render a component where @Inject NavigationManager SiteNavigationManager is used to inject the Navigation manager, how should I make this work with BlazorTemplater?

Thank you,
ed

The use-cases for BlazorTemplater don't really make sense to have a NavigationManager as they are rendering HTML only. If it's not removable then you might try creating an instance of it directly in your service container using a subclass.

See https://stackoverflow.com/questions/64466099/how-to-inject-navigationmanager-in-bunit-blazor-component-unit-test for an example.

You would add the instance thus:

services.AddSingleton<NavigationManager, TestNav>();

(very rough code, not tested!)