title: Creating ASP MVC custom views with automatic ng-bind
body: <p>I am thinking of doing the bind coding task on the server side. Let me describe. In ASP MVC i was making a viewmodel for each page then by taking help of @Html.EditorFor and others, I was making the view part. Now i want to make a logical relation between server side ViewModel and the one in the Scope of angular controller. I have an idea of making a DisplayTemplate and a EditorTemplate for each type of field then I put the ng-bind attribute in them, so every thing sounds good except two:</p>
  
  <ol>
  <li><p>How can I make an IScope of elements on the page automatically?</p></li>
  <li><p>In the templates I should use ng-model for example with a text in value. I want the text be the name of the field that this template goes on its UIHint. So how to do that job?</p></li>
  </ol>
  
  <h2>Edit</h2>
  
  <p>I forgot to say that I am using TypeScript on client side, the question one was all about this. I want to make an interface (IPageScope) for the controller over the viewmodel used in that.</p>
  
  <h2>Second problem solved</h2>
  
  <p><a href="https://stackoverflow.com/questions/6615541/how-to-get-models-field-name-in-custom-editor-template">How to get model&#39;s field name in custom editor template</a></p>
  
  <p>I was looking for something like this:</p>
  
  <pre><code>@{ string modelName = ViewData.ModelMetadata.ContainerType.Name + "." + ViewData.ModelMetadata.PropertyName;}
  
  &lt;h3 ng-model="@modelName"&gt;
      Hello World @ViewData.ModelMetadata.ContainerType || @ViewData.ModelMetadata.ContainerType.Name || @ViewData.ModelMetadata.PropertyName || @ViewData.TemplateInfo.HtmlFieldPrefix
  &lt;/h3&gt;
  </code></pre>
  
  <p>Now the model name is generated by the class name and property name.</p>
  
  <p>What about the first one? is there any way to auto generate this scope parameters of ViewModel in an IScope interface in TypeScript file for further use?</p>