I have a question about structuring my design for SoC (Separation of Concerns). I currently have the following files:
- testController.cs
- testViewModel.cs
- testView.cshtml
- testScript.js
Currently, I generate data in the controller, populate the testViewModel, and pass it to the Razor view. Inside the Razor view, I can directly use the data like this:
<script>
var someVariable = @Model.someVariable;
</script>
Everything works fine until I try to move my JavaScript code into a separate file.
What is the best way to access the data in a variable that is located in a JavaScript file?
That's my main question. Additionally, once I solve this issue, I'd like to incorporate VueJs in a separate file as well.
However, I'm unsure how to pass data from the Razor view to the Vue data variable.
What would be the best practice for achieving this?