-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
Hi there,
Firstly, I want to express my gratitude for your incredible NuGet package. It has been extremely useful in my projects.
I'm currently working with a Blazor component and facing a challenge in accessing a Razor component's parameters within a JavaScript file. Any guidance on this would be greatly appreciated.
Here's the specific scenario:
Weather.razor (work)
<PageTitle>Weather</PageTitle>
<script>
var weather = `@Content`;
console.log(weather);
</script>
@Content
@code {
[Parameter] public required string Content { get; set; }
}
Weather.razor (not work)
<PageTitle>Weather</PageTitle>
<PageScript Src="./Components/Pages/Weather.razor.js" />
@Content
@code {
[Parameter] public required string Content { get; set; }
}In the above Razor component, I am trying to pass the Content parameter value to the embedded JavaScript.
Weather.razor.js
export function onLoad() {
console.log('Load');
// Question: How can I access the `Content` parameter from the Razor component here?
// For example, I'd like to do something like this:
// console.log(@Content);
}
export function onUpdate() {
console.log('Update');
}
export function onDispose() {
console.log('Dispose');
}In the isolated JavaScript file, I'm unsure how to access the Content parameter defined in the Razor component.
Could you provide some insights or suggestions on how to achieve this? Any help or direction would be greatly appreciated.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels