serdarciplak / BlazorMonaco

Blazor component for Microsoft's Monaco Editor which powers Visual Studio Code.
https://serdarciplak.github.io/BlazorMonaco/
MIT License
432 stars 98 forks source link

Unable to bind value to c# object. #107

Closed mpicca1 closed 6 months ago

mpicca1 commented 10 months ago

Hello, how do I @bind-Value to this component? I want to link the data. Is there a way to data-bind the value to a string or a string property of an object?

35P10 commented 8 months ago

Hi, try this:

<StandaloneCodeEditor @ref="_editor"  OnDidChangeModelContent="HandleInput">

@code
{
     private string code = "";
     private StandaloneCodeEditor _editor = null!;

     private async Task HandleInput(ModelContentChangedEvent e)
     {
          code = await _editor.GetValue();
     }
}

It works for me.

serdarciplak commented 6 months ago

Duplicate of #55