Here's my code
@Component({
template: `<h1>Hello from A</h1>
<ul>
<li *ngFor="#letter of letters; #i = index">
<button (click)="appendW(i)">{{letter | uppercase}}</button>
</li>
</ul>
<button (click)="doSomething()">Click</button>`,
pipes: [UpperCasePipe],
directives: [NgFor]
})
export class AComponent {
letters = ['a','b','c','d'];
contructor(){
}
appendW(index) {
// console.log(letter);
setTimeout(()=>{
this.letters[index] += "W";
}, 1000)
}
...
}
Plnkr
After setTimeout, angular checks twice for content and view. Can somebody explain this? Why does angular need to check TWICE?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…