p4.component.ts 816 Bytes
Newer Older
李彥志's avatar
李彥志 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
import { Component, OnInit } from '@angular/core';

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

  number = '';
  value2: any;

  addNumber(inputRef: HTMLInputElement): void {
    console.log(inputRef.value);
    inputRef.value = '';

李彥志's avatar
李彥志 committed
17
    this.value2 = new Number(inputRef.value);
李彥志's avatar
李彥志 committed
18 19

    if (
李彥志's avatar
李彥志 committed
20
      this.value2 === 0
李彥志's avatar
李彥志 committed
21 22 23 24 25 26 27
    ) {
      alert('good');
    } else {
    alert('請輸入0');
    }
  }

李彥志's avatar
李彥志 committed
28 29 30 31
  addNumber2(inputRef: HTMLInputElement): void {
    console.log(inputRef.value);
    inputRef.value = '';

32
    this.value2 = new Number(inputRef.value);
李彥志's avatar
李彥志 committed
33 34

    if (
35
      this.value2 !== Number
李彥志's avatar
李彥志 committed
36 37 38 39 40 41 42
    ) {
      alert('bye');
    } else {
    alert('okay~');
    }
  }

李彥志's avatar
李彥志 committed
43 44 45 46 47 48 49 50


  constructor() { }

  ngOnInit() {
  }

}