this.viewSegmentsForAnalysis = this.segmentsForAnalysis;
을 ngOnInit()
동안 한 번만 설정하고 싶습니다. 그러나이 메서드를 호출하면 this.viewSegmentsForAnalysis
의 값이 this.segmentsForAnalysis
으로 업데이트됩니다. 업데이트를 유발할 수있는 원인은 무엇입니까?아무 이유없이 각도 4 속성 업데이트
ngOnInit() {
this.segmentsForAnalysis = this.submissionDetails.segmentations.filter((segment) => {
return segment.columns.length === 1;
});
this.viewSegmentsForAnalysis = this.segmentsForAnalysis;
}
addSegmentsForAnalysis() {
this.segmentsForAnalysis.push({
name: this.fileColumn.value,
overlapAnalysis: false,
columns: [{
index: segmentIndex,
name: this.segmentTitle.value
}]
});
}
'때문에 방법으로 업데이트지고 같은 개체에 this.viewSegmentsForAnalysis' 점. – Jai
어떻게'this.viewSegmentsForAnalysis = this.segmentsForAnalysis; '를'ngOnInit()'에 한 번만 설정할 수 있습니까? –
'this.viewSegmentsForAnalysis = this.segmentsForAnalysis.slice(); '사용 – Jai