p3.component.ts 696 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
  imageUrl = 'http://lorempixel.com/{{widthLength}}/{{heightLength}}/';
李彥志's avatar
李彥志 committed
13

李彥志's avatar
李彥志 committed
14 15 16
  showPic() {
    if (this.widthLength !== null && this.heightLength !== null &&
      this.widthLength !== undefined && this.heightLength !== undefined) {
李彥志's avatar
李彥志 committed
17
      this.imageUrl = 'http://lorempixel.com/' + this.widthLength + '/' + this.heightLength + '/';
李彥志's avatar
李彥志 committed
18
    } else {
李彥志's avatar
李彥志 committed
19
      alert('長度或高度不得為空!');
李彥志's avatar
李彥志 committed
20
    }
李彥志's avatar
李彥志 committed
21 22
  }

李彥志's avatar
李彥志 committed
23 24 25 26
  constructor() { }

  ngOnInit() { }

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