From e9ba74761ddd803b527ba12c09b6645d974f9ae7 Mon Sep 17 00:00:00 2001 From: SteveSandersonMS Date: Mon, 14 Dec 2015 12:43:56 +0000 Subject: [PATCH] Fixes --- samples/angular/MusicStore/Apis/AlbumsApiController.cs | 2 +- .../wwwroot/ng-app/components/admin/album-edit/album-edit.ts | 4 ++-- .../wwwroot/ng-app/components/admin/form-field/form-field.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/samples/angular/MusicStore/Apis/AlbumsApiController.cs b/samples/angular/MusicStore/Apis/AlbumsApiController.cs index 55c4518..4d06656 100644 --- a/samples/angular/MusicStore/Apis/AlbumsApiController.cs +++ b/samples/angular/MusicStore/Apis/AlbumsApiController.cs @@ -98,7 +98,7 @@ namespace MusicStore.Apis if (!ModelState.IsValid) { // Return the model errors - return new ValidationErrorResult(ModelState); + return HttpBadRequest(ModelState); } // Save the changes to the DB diff --git a/samples/angular/MusicStore/wwwroot/ng-app/components/admin/album-edit/album-edit.ts b/samples/angular/MusicStore/wwwroot/ng-app/components/admin/album-edit/album-edit.ts index 7f1b4e0..1c5834c 100644 --- a/samples/angular/MusicStore/wwwroot/ng-app/components/admin/album-edit/album-edit.ts +++ b/samples/angular/MusicStore/wwwroot/ng-app/components/admin/album-edit/album-edit.ts @@ -89,8 +89,8 @@ export class AlbumEdit { }); } - public get formErrors() { - return Object.keys(this.form.errors || {}); + public get formErrors(): string[] { + return this.form.dirty ? Object.keys(this.form.errors || {}) : []; } } diff --git a/samples/angular/MusicStore/wwwroot/ng-app/components/admin/form-field/form-field.ts b/samples/angular/MusicStore/wwwroot/ng-app/components/admin/form-field/form-field.ts index 7cf7a30..b7c2cd8 100644 --- a/samples/angular/MusicStore/wwwroot/ng-app/components/admin/form-field/form-field.ts +++ b/samples/angular/MusicStore/wwwroot/ng-app/components/admin/form-field/form-field.ts @@ -12,7 +12,7 @@ export class FormField { private validate: ng.AbstractControl; public get errorMessages() { - var errors = (this.validate && this.validate.touched && this.validate.errors) || {}; + var errors = (this.validate && this.validate.dirty && this.validate.errors) || {}; return Object.keys(errors).map(key => { return 'Error: ' + key; });