title: Passing .net core model data to external javascript?
body: <p>I have a .NET Core 2 Razor view with the underlying model inside  a *.cshtml.cs file. Let's say I have a string like this: </p>
  
  <pre><code>public string myVar = "hello world";
  </code></pre>
  
  <p>How can I access this variable (data) inside my external JavaScript file?</p>
  
  <p>I need this for example in the following case. I'm using the jVectorMap jquery library. There I can select multiple regions of the map. I have to save the selected regions (let's say in an array of unique ids) so that I can pre-populate the map with the selected regions, if the user loads the special page with the map inside. And the data (selected regions) can be different do different users. So I have to store the data for each user and the have to load the data. jVectorMap has an API function which allows to pre-populate the map with some data.</p>
  
  <p>But how can I access my saved variable / data inside the external javascript file?</p>
  
  <p><strong>EDIT:</strong>
  I added an example here: <a href="https://dotnetfiddle.net/QV4Fi1" rel="noreferrer">https://dotnetfiddle.net/QV4Fi1</a></p>