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 = ''; inputRef.value = this.value2; if ( this.value2 = 0 ) { alert('good'); } else { alert('請輸入0'); } } constructor() { } ngOnInit() { } }