title: Client-side web app consuming Web API, how to populate select box field values based on expectations of server-side Web API?
body: <p>I am working in a web application which has a server powered by ASP.NET Core MVC and the frontend is an Angular 5.0 Single Page Application using TypeScript.</p>
  
  <p>In the client I have a page with a form and some <code>&lt;select&gt;</code> input controls. My design challenge here is that the choices in the <code>&lt;select&gt;</code> should be restricted to what values the Web API in my .NET Core expect.</p>
  
  <p>Since the server and the client application are part of the same Visual Studio solution I wanted to try to minimize breaking changes in the Web API. One way I thought I might be able to do this is to have the client-side forms and inputs be somewhat dumb and to request from the server the valid values to populate the <code>&lt;select&gt;</code> controls with. This way I don't have to duplicate logic in the client and the server (For instance, if I defined an Enum in C# and again in TypeScript). There's a few down sides to this though that I can think of (like if I wanted to toggle visibility of other form fields based on the <code>&lt;select&gt;</code> value, I would have to hard-code logic in the client which makes assumptions about values.</p>
  
  <p>Is this a good idea? What kind of other solutions could I use?</p>