While browsing online, I came across a post discussing how to transfer data from an MVC model to a .ts file. The suggestion was to include the following code:
<script type="text/javascript">
var testUrl = @Html.Raw(Json.Encode(Model.testUrl))
</script>
In my .ts file, I have the following code which utilizes the testUrl:
PerformJob(id) {
var src = `${testUrl}{id}`
fetch(src);
}
However, during the build process with gulp, I encountered an error: error TS2304: Cannot find name 'testUrl'. How can I address this undefined error when the value in the ts file is derived from the model? Is there a more efficient method of passing data from the model to ts rather than a global parameter?
Any assistance on this matter would be greatly appreciated.