Skip to content

Commit

Permalink
After save or update, redirect user to the owner detail page
Browse files Browse the repository at this point in the history
  • Loading branch information
arey committed Mar 28, 2017
1 parent 4837b84 commit 26310ca
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/app/owners/owner-add/owner-add.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export class OwnerAddComponent implements OnInit {

owner: Owner;
errorMessage: string;
added_success: boolean = false;

constructor(private ownerService: OwnerService, private router: Router) {
this.owner = <Owner>{};
Expand All @@ -47,8 +46,8 @@ export class OwnerAddComponent implements OnInit {
owner.id = null;
this.ownerService.addOwner(owner).subscribe(
new_owner => {
this.added_success = true;
return this.owner = new_owner;
this.owner = new_owner;
this.gotoOwnersList();
},
error => this.errorMessage = <any>error
);
Expand Down
6 changes: 5 additions & 1 deletion src/app/owners/owner-edit/owner-edit.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export class OwnerEditComponent implements OnInit {
}

onSubmit(owner) {
var that = this;
this.ownerService.updateOwner(owner.id.toString(), owner).subscribe(
get_result,
get_error
Expand All @@ -61,7 +62,8 @@ export class OwnerEditComponent implements OnInit {
function get_result(update_status) {
console.log(update_status);
if (update_status.status === 204) {
return console.log('update success');
console.log('update success');
that.gotoOwnerDetail(owner);
} else {
return console.log('update failed');
}
Expand All @@ -72,4 +74,6 @@ export class OwnerEditComponent implements OnInit {
this.router.navigate(['/owners', owner.id]);
}



}

0 comments on commit 26310ca

Please sign in to comment.