mensaje-final.component.ts 970 Bytes
import { Component, OnInit } from '@angular/core';
import { appSettings } from 'src/etc/AppSettings';
import { ProductoService } from 'src/app/services/producto.service';
import { Router } from '@angular/router';

@Component({
  selector: 'app-mensaje-final',
  templateUrl: './mensaje-final.component.html',
  styleUrls: ['./mensaje-final.component.scss']
})
export class MensajeFinalComponent implements OnInit {

  private apiUrl: string = appSettings.apiUrl;
  private timer: any;

  constructor(
    private productoService: ProductoService,
    private router: Router
  ) { }

  ngOnInit() {

    this.timer = setTimeout(() => {
      
      this.limpiarCarritoYvolver();
    }, 30000)
  }

  ngOnDestroy() {

    clearTimeout(this.timer);
  }

  limpiarCarritoYvolver() {

    this.productoService.productoAcargar = undefined;
    this.productoService.promoAcargar = undefined;
    this.productoService.productos = [];
    this.router.navigate(['/home']);
  }

}