0
我无法理解这里的错误在哪里。Angular 2(click)不起作用
add.component.ts:
import { Component } from '@angular/core';
@Component({
selector: 'counter',
templateUrl: './add.component.html'
})
export class CounterComponent {
public currentCount = 0;
public incrementCounter() {
this.currentCount++;
}
}
add.component.html:
<h1>Counter</h1>
<p>This is a simple example of an Angular component.</p>
<p>Current count: <strong>{{ currentCount }}</strong></p>
<button (click)="incrementCounter()">Increment</button>
当我按一下按钮,没有任何反应。
创建可能的话 – Faisal
,能得到任何控制台误差的plunker?据我所知,这应该起作用。 –
按预期工作,这里是一个plunk:https://plnkr.co/edit/0eGfLSzZjhr9a6vtDhdC – Faisal