【发布时间】:2019-11-21 09:50:40
【问题描述】:
我刚开始使用 Angular 和初学者。
当我在我的组件中使用 *ngIf 或 *ngFor 时,程序输出是一个空白页面但没有 *ngIf 和 *ngFor 页面可以正常工作。
Product.Component.html的代码
<p>Q: what is your Name?<input [disabled]="isButtonDisable" type="text" #txtAnswer>
<button [disabled]="product.price>1000" (click)="onclickHandler(txtAnswer.value)">Answer</button>
<h3 *ngIf="isButtonDisable">{{deadline}}</h3>
</p>
product.component.ts的代码
import { Component } from '@angular/core';
@Component({
selector: 'app-product',
templateUrl: './product.component.html',
styleUrls: ['./product.component.css']
})
export class ProductComponent {
public isButtonDisable = false;
public product = {
name: 'car',
price: 1000
};
public deadline = 20;
constructor() {
setInterval(() => this.deadline--, 1000);
setInterval(() => this.isButtonDisable = true, 20000);
}
onclickHandler(Value: number) {
this.deadline = 20;
}
}
我的 IDE 是 vscode 和
Angular CLI:8.1.1
节点:10.15.2
操作系统:win32 x64
角度:8.1.0
请指导我哪里错了:(
【问题讨论】:
-
我刚刚使用你的代码构建了一个stackBlitz,我可以看到页面[Your code in stackBlitz][1] [1]:stackblitz.com/edit/angular-ch2gx4?file=src/app/…
标签: angular visual-studio-code angular-directive ngfor angular-ng-if