79421041

Date: 2025-02-07 13:30:58
Score: 2
Natty:
Report link

This ended up being a problem with change detection. Once I set up a way to force change detection in the modal component, I was able to see the desired result. I have to call the detectChanges function in the modal component from the component where I am opening the modal by accessing the componentInstance property. This feels a little hacky to me, so if anyone has a better solution, I would appreciate your input.

@Component({
  standalone: true,
  imports: [CommonModule, NgbModule, NgbModalModule],
  selector: 'app-create-order-modal',
  templateUrl: './create-order-modal.component.html',
  styleUrls: ['./create-order-modal.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class CreateOrderModalComponent {
  items?: AutoStartItem[];
  pristine = true;

  constructor(public modal: NgbActiveModal, private changeDetector: ChangeDetectorRef) { }

  detectChanges(): void {
    this.changeDetector.detectChanges();
  }
}
Reasons:
  • Blacklisted phrase (1.5): would appreciate
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: slyDog