I have HTML view which has ViewBag list as you can see in the code below.
```
<select asp-for="categoryName" id="CatId" name="purchase[0].categoryName" class="form-control" style="border-radius: 12px; " asp-items="@ViewBag.Pitems">
<option>Select Category</option>
</select>
<select asp-for="type" id="typeId" name="purchase[0].type" class="form-control" style="border-radius: 12px; " asp-items="@(new SelectList(string.Empty, "type", "type"))">
<option>Select Type</option>
</select>
Now for other page want to use same thing but it is in javascript, When I write this code in Javascript ViewBag is not working
var counter - 1; '
<select class="form-control" asp-for="categoryName" name="purchase[' + counter + '].categoryName" style="border-radius: 12px; " id="cat1" onchange="change1(' + counter + ', this) asp-items="@ViewBag.Pitems";>'
This code is showing no value in dropdown, how to code javascript dropdown list which access ViewBag>