question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support to @inject

See original GitHub issue

Hi!

I’m trying to use @inject to inject via .netCore DI system some services in my View. But “@inject” it’s not a known tag in RazorLight.

Can you implement this in some future version? Do you want some help to do this?

To now I use a workaround.

Rather than @inject IServiceUri ServiceUri

I used @{var ServiceUri = new ServiceUri();}

But… I lost DI 😢

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
toddamscommented, Aug 31, 2016
  • Add package

    Install-Package RazorLight.MVC

  • Add RazorLight services in Startup.cs

        public void ConfigureServices(IServiceCollection services)
        {
            ....
            services.AddRazorLight("/Views"); // <- This one
            ....
        }
  • Inject services to your templates
@inject MyProject.TestViewModel myModel
1reaction
toddamscommented, Aug 22, 2016

@inject is a feature of ASP.NET MVC, but I planned to add an integration Expect this on beta5 release

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why Angular 14's new inject() function is so amazing?
But if you use the inject() function you dont even need a service as a dependency in your component, you just need to...
Read more >
Inject (Java EE 6 )
javax.inject. Annotation Type Inject ... Identifies injectable constructors, methods, and fields. May apply to static as well as instance members. An injectable ......
Read more >
Assisted Injection
Assisted injection is a dependency injection (DI) pattern that is used to construct an object where some parameters may be provided by the...
Read more >
What is the difference between @Inject and @Autowired in ...
Spring has chosen to support using the @Inject annotation synonymously with their own @Autowired annotation. So, to answer your question, ...
Read more >
Understanding dependency injection
When you provide the service at the root level, Angular creates a single, shared instance of the HeroService and injects it into any...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found