pQuestions123
pQuestions123

Reputation: 4611

set javascript variable toe evaluated viewbag expression

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

Answers (1)

Anish Patel
Anish Patel

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

Related Questions