import { Component } from '@angular/core';
@Component({
selector: 'app-root',
// templateUrl: './app.component.html',
template:`
<div *ngFor="let v of getArray();">
{{v}}
</div>
`,
styleUrls: ['./app.component.css']
})
export class AppComponent {
getArray(){
console.log("getArray");
return [1,2,3,5,6];
}
}
上記を実行するとlogに
11:17:30.567 app.component.ts:15 getArray
11:17:30.578 app.component.ts:15 getArray
11:17:30.579 lang.js:130 Angular is running in the development mode. Call enableProdMode() to enable the production mode.
11:17:30.581 app.component.ts:15 getArray
11:17:30.582 app.component.ts:15 getArray
と表示されます。なぜ4回も実行されるのでしょうか?