Reputation: 4611
I would like to set a javascript variable to the result of a viewbag expression. How can I do what this?
I know this is not right:
$scope.userPermissions = {
manageUsers: '@ViewBag.IS_MANAGE_USER == 1',
};
Upvotes: 1
Views: 28
Reputation: 4392
If you want manageUsers
to be a bool, i.e. true
or false
then you can do this:
$scope.userPermissions = {
manageUsers: @(ViewBag.IS_MANAGE_USER == 1 ? "true" : "false"),
};
Upvotes: 1