I am trying to send a string value from my controller action on my view using View Bag like this
public ActionResult Services()
{
ViewBag.TabVal = "EarnMoney";
return View();
}
On my view I am assigning the View Bag value to a JavaScript variable like this
@section scripts{
<script>
var tab = @ViewBag.TabVal;
console.log(tab);
</script>
}
on my console I get this value
<li id="EarnMoney"> EarnMoney</li>
which is an HTML element on my view.
Why is it selecting the element on my view and not giving a string in return ?This is really weird behavior.