-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
✔️ Resolution: AnsweredResolved because the question asked by the original author has been answered.Resolved because the question asked by the original author has been answered.Status: Resolvedarea-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor Componentsquestion
Description
Is your feature request related to a problem? Please describe.
Sometimes I have to pass HTML to JavaScript to use it in a JavaScript-enhanced element (Bootstrap "plugin"). It would be useful to be able to reuse an existing razor component by saving the output it would render to a string and passing it on to JavaScript.
Describe the solution you'd like
Given a component MyComponent.razor:
<h1>@Title</h1>
<p>@Description</p>
code {
[Parameter]
public string Title { get; set; }
[Parameter]
public string Description { get; set; }
}
Save its output to a string and use like:
<div class="my-plugin" data-content="@myComponentOutput"></div>
code {
private string myComponentOutput;
private MyComponent myComponent;
protected override void OnInitialized()
{
myComponentOutput = myComponent.GetOutput(Title: "Hello", Description: "Just saying hello");
}
}
Metadata
Metadata
Assignees
Labels
✔️ Resolution: AnsweredResolved because the question asked by the original author has been answered.Resolved because the question asked by the original author has been answered.Status: Resolvedarea-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor Componentsquestion