title: Use injected service from JS code to static Blazor method
body: <p>I have an app that uses a jQuery lib to show 'confirmation' dialogs. </p>
  
  <p>When a user clicks 'OK' or 'Cancel' on the dialog, then first a callback is made to my Javascript code. From there I do a call to a Blazor method, based on the decision the user made.</p>
  
  <p>This all looks something like this:</p>
  
  <p>My js code:</p>
  
  <pre><code>$('.alert-yesno).on('click', function() {
      // For simplicity I immediately call the Blazor method
      DotNet.invokeMethodAsync('[Assembly name]', 'DoSomething')
                              .then(data =&gt; {
                                  // do something...
                              });
  });
  </code></pre>
  
  <p>Blazor page:</p>
  
  <pre><code>@inject MyService MyService
  
  &lt;button class="alert-yesno"&gt;Show dialog&lt;/button&gt;
  
  @code
  {
      [JSInvokable]
      public static async Task DoSomething()
      {
          // How to use the non static MyService here...?
      }
  }
  </code></pre>
  
  <p>This all works fine. The Javascript part calls my Blazor method. But how can I use <code>MyService</code> from there? This is injected into the page. Which is good, because it makes use of dependency injection.</p>
  
  <p>I don't want to create a <code>new</code> instance everytime from within the <code>static</code> method, because that way I loose all the auto injected dependencies.</p>
  
  <p>How can I solve this issue?</p>