我想要得到的步驟舊值,而不是最新之後我點擊了提交,我的init()我有這樣的代碼角2 - 獲取舊值
export class BakingProcedureItemComponent implements OnInit {
steps: Array<string> = [];
ngOnInit() {
this.steps.push("test");
this.currentSteps = this.steps;
if(!this.isNew){
this.service.get(id).subscribe(item => {
this.steps = item;
});
}
}
onSubmit({value, valid}: {value: BakingProcedure, valid: boolean}): void {
console.log(this.currentSteps); //output ['test'] not []
}
}
它輸出最新值不是['test']
。如何在推動之前獲得舊價值。
複製陣列,例如。 –