0

I am newbie in Angular and sending ViewBag data from ActionResult into the View. where in the view i want to access the ViewBag and put the content in the $scope object like

$scope.productList = ViewBag.productList;

but not having any idea about how to do this. Please suggest any reference.

Update:

I tried to get the ViewBag object in Window scope and then window scope to $scope object. but it does not work out.

        <script>
            window.Category = [];
            @foreach (var listItem in (IEnumerable<SelectListItem>)ViewBag.Categories)
            {
                window.Category.Add(listItem.Text);
            }


        </script>
Mohit
  • 2,189
  • 4
  • 22
  • 40

1 Answers1

0

try using <script type="text/javascript"> that allowed you to mix razor and javascript

see hare and hare

Community
  • 1
  • 1
oCcSking
  • 888
  • 21
  • 43