-
Notifications
You must be signed in to change notification settings - Fork 233
Labels
affected-fewarea-blazorarea-compilerUmbrella for all compiler issuesUmbrella for all compiler issuesbugSomething isn't workingSomething isn't workingseverity-nice-to-have
Milestone
Description
I’ve just started to play around with Blazor and tried to write this code in a .razor-file:
<span class="@if(sortType != 0) { <text>btn-primary</text> } else { <text>btn-success</text> }">
Yes, not very elegant :-) Either way, I got this error message that confuses me:
Code blocks delimited by '@{...}' like '@{ if(sortType != 0) { } }' for attributes are no longer supported These features have been changed to use attribute syntax. Use 'attr="@(x => {... }"'.
I’ve tried to rewrite me code to use lambda expression as suggested, but whatever I do a get an error message. Is this possible in this case? I’ve noticed that a lambda expression works fine if the attribute is @onclick.
If I rewrite my code like this it works, but that is not was the error message suggest:
<span class="btn @(sortType != 0 ? "btn-primary" : "btn-success")">
VonPittman, publicmessages, Apollo3zehn and clarity99Copilot
Metadata
Metadata
Labels
affected-fewarea-blazorarea-compilerUmbrella for all compiler issuesUmbrella for all compiler issuesbugSomething isn't workingSomething isn't workingseverity-nice-to-have