p3.component.ts 642 Bytes
Newer Older
李彥志's avatar
李彥志 committed
1 2 3 4 5 6 7 8 9
import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-p3',
  templateUrl: './p3.component.html',
  styleUrls: ['./p3.component.css']
})
export class P3Component implements OnInit {

李彥志's avatar
李彥志 committed
10 11
  widthLength = '1024';
  heightLength = '768';
李彥志's avatar
李彥志 committed
12 13 14 15 16
  imageUrl = null;

  ngOnInit() {
    this.showPic();
  }
李彥志's avatar
李彥志 committed
17

李彥志's avatar
李彥志 committed
18 19 20
  showPic() {
    if (this.widthLength !== null && this.heightLength !== null &&
      this.widthLength !== undefined && this.heightLength !== undefined) {
李彥志's avatar
李彥志 committed
21
      this.imageUrl = 'https://lorempixel.com/' + this.widthLength + '/' + this.heightLength + '/';
李彥志's avatar
李彥志 committed
22
    } else {
李彥志's avatar
李彥志 committed
23
      alert('null');
李彥志's avatar
李彥志 committed
24
    }
李彥志's avatar
李彥志 committed
25 26
  }

李彥志's avatar
李彥志 committed
27 28
  constructor() { }

李彥志's avatar
李彥志 committed
29
}