Commit bb26145167375b229a3fe7e7d226468c6e2368e2
1 parent
bab0235720
Exists in
master
and in
1 other branch
Arreglo con timeout.
Showing
1 changed file
with
9 additions
and
3 deletions
Show diff stats
src/app/components/cancelar-compra/cancelar-compra.component.ts
1 | -import { Component, OnInit } from '@angular/core'; | |
1 | +import { Component, OnInit, OnDestroy } from '@angular/core'; | |
2 | 2 | import { appSettings } from 'src/etc/AppSettings'; |
3 | 3 | import { Location } from '@angular/common'; |
4 | 4 | import { Router } from '@angular/router'; |
... | ... | @@ -9,9 +9,10 @@ import { ProductoService } from 'src/app/services/producto.service'; |
9 | 9 | templateUrl: './cancelar-compra.component.html', |
10 | 10 | styleUrls: ['./cancelar-compra.component.scss'] |
11 | 11 | }) |
12 | -export class CancelarCompraComponent implements OnInit { | |
12 | +export class CancelarCompraComponent implements OnInit, OnDestroy { | |
13 | 13 | |
14 | 14 | private apiUrl: string = appSettings.apiUrl; |
15 | + private timer: any; | |
15 | 16 | |
16 | 17 | constructor( |
17 | 18 | private location: Location, |
... | ... | @@ -21,11 +22,16 @@ export class CancelarCompraComponent implements OnInit { |
21 | 22 | |
22 | 23 | ngOnInit() { |
23 | 24 | |
24 | - setTimeout(() => { | |
25 | + this.timer = setTimeout(() => { | |
25 | 26 | this.limpiarCarritoYvolver(); |
26 | 27 | }, 30000) |
27 | 28 | } |
28 | 29 | |
30 | + ngOnDestroy() { | |
31 | + | |
32 | + clearTimeout(this.timer); | |
33 | + } | |
34 | + | |
29 | 35 | volverPreviousPage() { |
30 | 36 | |
31 | 37 | this.location.back(); |