@attribute in an HTML element
Attach a dictionary of attributes to the element.
Example
<h3 @attributes="Dictionary">Attribute</h3>
@code {
Dictionary<string, object> Dictionary = new Dictionary<string, object>()
{
{ "example","true" },
{ "score", 10 },
{ "object", new
{
Number = 100,
Text = "Test"
}
}
};
}
Rendered HTML
<h3 example="true" score="10" object="{ Number = 100, Text = Test }">Attribute</h3>
@attribute in directive section
Set an attribute for a component.
Example
@attribute [Route("/attribute-in-directive-section")]
<h3>AttributeInDirectiveSection</h3>
Will equalize to
@page "/attribute-in-directive-section"
<h3>AttributeInDirectiveSection</h3>
The Blazor .NET 6 Fundamentals book are available in ebook and paperback!