Commit 580a4bb4c73b953555b4de35b3cd0c49d1432033
1 parent
455398b6ee
Exists in
master
and in
1 other branch
Timer de tiempo de pantalla en reposo, para inicio y busqueda productos.
Showing
2 changed files
with
31 additions
and
4 deletions
Show diff stats
src/app/components/master/master.component.html
src/app/components/master/master.component.ts
| 1 | -import { Component, OnInit } from '@angular/core'; | |
| 1 | +import { Component, OnInit, OnDestroy } from '@angular/core'; | |
| 2 | +import { Router } from '@angular/router'; | |
| 2 | 3 | |
| 3 | 4 | @Component({ |
| 4 | 5 | selector: 'app-master', |
| 5 | 6 | templateUrl: './master.component.html', |
| 6 | 7 | styleUrls: ['./master.component.scss'] |
| 7 | 8 | }) |
| 8 | -export class MasterComponent implements OnInit { | |
| 9 | +export class MasterComponent implements OnInit, OnDestroy { | |
| 9 | 10 | |
| 10 | - constructor() { } | |
| 11 | + private timerReposo: any | |
| 12 | + | |
| 13 | + constructor( | |
| 14 | + private router: Router | |
| 15 | + ) { } | |
| 11 | 16 | |
| 12 | 17 | ngOnInit() { |
| 18 | + | |
| 19 | + this.timerReposo = setTimeout(() => { | |
| 20 | + | |
| 21 | + this.router.navigate(['cancelar-compra']); | |
| 22 | + }, 90000) | |
| 23 | + } | |
| 24 | + | |
| 25 | + ngOnDestroy() { | |
| 26 | + | |
| 27 | + clearTimeout(this.timerReposo); | |
| 28 | + } | |
| 29 | + | |
| 30 | + reiniciarTimer() { | |
| 31 | + | |
| 32 | + clearTimeout(this.timerReposo); | |
| 33 | + this.timerReposo = setTimeout(() => { | |
| 34 | + | |
| 35 | + this.router.navigate(['cancelar-compra']); | |
| 36 | + }, 90000) | |
| 37 | + | |
| 13 | 38 | } |
| 14 | 39 | |
| 15 | 40 | } |