Advertisement
coffeecode12

home

Jul 14th, 2022
1,096
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { Component, OnInit } from '@angular/core';
  2. import { Title } from '@angular/platform-browser';
  3. import { Router } from '@angular/router';
  4. import { Location } from '@angular/common';
  5. import { StoreFrontService } from 'src/app/module/store-front/store-front.service';
  6. import { Section } from 'src/app/model/response/section';
  7.  
  8. @Component({
  9.   selector: 'app-home-page',
  10.   templateUrl: './home-page.component.html',
  11.   styleUrls: ['./home-page.component.scss']
  12. })
  13. export class HomePageComponent implements OnInit {
  14.   datasection?: Section;
  15.   loading = false;
  16.   route?:string;
  17.  
  18.  
  19.   constructor(
  20.     private titleService: Title,
  21.     private storefrontservice: StoreFrontService,
  22.     private location: Location,
  23.     private router: Router,
  24.   ) {
  25.     this.titleService.setTitle('TELKOMSEL API Marketplace');
  26.  
  27.     router.events.subscribe(
  28.       (val) => {
  29.         if (location.path() === '') {
  30.           this.route = location.path();
  31.         }
  32.       });
  33.   }
  34.  
  35.  
  36.   ngOnInit() {
  37.     this.refreshList();
  38.   }
  39.  
  40.  
  41.   refreshList() {
  42.     this.loading = true;
  43.     this.storefrontservice.getHomePage().subscribe((res:any) => {
  44.       this.datasection = res.data;
  45.       this.loading = false;
  46.     },
  47.       (error:any) => {
  48.         this.loading = false;
  49.         console.log(error);
  50.       });
  51.   }
  52.  
  53.  
  54. }
  55.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement