Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

DataAnnotations with TypeScript/Angular 2

$
0
0

We have a number of Models with validation enforced via the DataAnnotation tags.  Example:

    [Required(AllowEmptyStrings = false, ErrorMessage = "Username is required")]

    public string UserName

We are now developing a .NET Core application with Angular 2 and would like to continue to use the Models and the validation they bring.  The edits should be enforced on the "Client" (Browser) as opposed to requiring a postback to get the validation errors.  Knockout has been used previously to implement this requirement.  But, I just want to use Angular 2 or TypeScript to implement the client-side edits.  Can this be done and could you please provide some examples of how to do it?


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>