equipment.component.ts 1.47 KB
Newer Older
1
import { Component, OnInit } from '@angular/core';
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
import {NgbModal, ModalDismissReasons} from '@ng-bootstrap/ng-bootstrap';

interface Country {
  id?: number;
  equip: string;
  name: string;
  sdate: string;
  edate: string;
}

const COUNTRIES: Country[] = [
  {
    equip: 'string',
    name: 'ray',
    sdate: 'string',
    edate: 'string'
  }

];
21 22 23 24 25 26 27

@Component({
  selector: 'app-equipment',
  templateUrl: './equipment.component.html',
  styleUrls: ['./equipment.component.scss']
})
export class EquipmentComponent implements OnInit {
28 29 30 31 32
  page = 1;
  pageSize = 10;
  collectionSize = COUNTRIES.length;
  countries: Country[];
  closeResult = '';
33

34
  constructor(private modalService: NgbModal) { }
35 36 37

  ngOnInit(): void {
  }
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
  
  open(content) {
    this.modalService.open(content, {ariaLabelledBy: 'modal-basic-title'}).result.then((result) => {
      this.closeResult = `Closed with: ${result}`;
    }, (reason) => {
      this.closeResult = `Dismissed ${this.getDismissReason(reason)}`;
    });
  }

  private getDismissReason(reason: any): string {
    if (reason === ModalDismissReasons.ESC) {
      return 'by pressing ESC';
    } else if (reason === ModalDismissReasons.BACKDROP_CLICK) {
      return 'by clicking on a backdrop';
    } else {
      return `with: ${reason}`;
    }
  }
  refreshCountries() {
    this.countries = COUNTRIES
      .map((country, i) => ({ id: i + 1, ...country }))
      .slice((this.page - 1) * this.pageSize, (this.page - 1) * this.pageSize + this.pageSize);
  }
Chanachai committed
61
}