Using Razor, how do I render a Boolean to a JavaScript variable?
You may also want to try:
isFollowing: '@(Model.IsFollowing)' === '@true'
and an ever better way is to use:
isFollowing: @Json.Encode(Model.IsFollowing)
Because a search brought me here: in ASP.NET Core, IJsonHelper
doesn't have an Encode()
method. Instead, use Serialize()
. E.g.:
isFollowing: @Json.Serialize(Model.IsFollowing)