Skip to content

Instantly share code, notes, and snippets.

@barbaraperim
Last active February 13, 2020 02:20
Show Gist options
  • Save barbaraperim/31ff0de9b39ffe1f4e8f4272a006eed1 to your computer and use it in GitHub Desktop.
Save barbaraperim/31ff0de9b39ffe1f4e8f4272a006eed1 to your computer and use it in GitHub Desktop.
Button click test - ts
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