如何增加變量角2 - 4如何增加變量角2 - 4
當我從第1頁轉到第2頁由於某些原因該變量(n)是 不增加
我希望每次頁面加載後增加1, 當我路由20次到這個頁面後,我想說20是可能的?
export class DashboardComponent implements OnInit, AfterViewInit {
n: number = 0; <<== i have this nuber and i want to add +1 every time but for some reason is not work
constructor(private router: Router) {
}
ngOnInit() {
}
ngAfterViewInit() {
// google.charts.setOnLoadCallback(() => this.chart_1('500', '100%'));
console.log('---------------------- ngAfterViewInit ---------------------------');
let chartwidth1 = $('#curve_chart1').width();
let chartwidth2 = $('#curve_chart2').width();
if (this.n === 0) {
chartwidth1 += 0;
chartwidth2 += 0;
} else {
chartwidth1 -= 50;
chartwidth2 -= 50;
}
console.log(chartwidth1);
console.log(chartwidth2);
console.log(this.n); <<== this is say 0
this.n += 1;
console.log(this.n); <<== this is say 1
// google.charts.setOnLoadCallback(() => this.chart_1((chartwidth1 - 80), '100%'));
this.chart_1((chartwidth1 - 80), '100%');
this.chart_2((chartwidth2 - 80), '100%');
}
}
對誰到這裏來只是爲了downvote的人來說,這個問題不來這裏只是幫助,如果你能,或者解釋爲什麼你downvote這個簡單的問題malakopitoures – George