1

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',
        };

1 Answer 1

1

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"),
    };
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.