Last active
February 13, 2020 02:20
-
-
Save barbaraperim/31ff0de9b39ffe1f4e8f4272a006eed1 to your computer and use it in GitHub Desktop.
Button click test - ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component } from '@angular/core'; | |
import { TestService } from './test-service/test.service'; | |
import { Router } from '@angular/router'; | |
@Component({ | |
selector: 'app-root', | |
templateUrl: './app.component.html', | |
styleUrls: ['./app.component.css'] | |
}) | |
export class AppComponent { | |
title = 'button-click-test'; | |
errorMessage = ''; | |
successMessage = ''; | |
constructor(private router: Router, private testService: TestService) { } | |
clickAction() { | |
this.testService.callAPI().subscribe( | |
(response) => { | |
this.successMessage = response.body.message; | |
this.router.navigate(['/teste']); | |
}, | |
errorResponse => { | |
this.errorMessage = errorResponse.message; | |
} | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment