垫选择超过800个选项中选择的最大呼叫堆栈大小

时间:2019-10-23 13:06:48

标签: angular-material

我正在使用mat-select来填充下拉列表中的对象数组。有一个选项可以通过单击全部来选择和取消选择所有值。为此,我要清空与其关联的表单控件,并选择所有表单控件,并使用所有id填充表单控件。对于Small Data,它的工作正常。对于超过800的数据,当我在取消选择al时清空formcontrol时,它将引发错误(超出最大调用堆栈大小     在SafeSubscriber.push ../ node_modules / rxjs / _esm5 / internal / Subscriber.js.SafeSubscriber .__ tryOrUnsub(Subscriber.js:200)     在SafeSubscriber.push ../ node_modules / rxjs / _esm5 / internal / Subscriber.js.SafeSubscriber.next(Subscriber.js:130)  )

component.html

 <mat-select [formControl]="courseFormControl" multiple aria-label="Course Name"
          [(ngModel)]="selectedCourseIds">
<mat-option *ngFor="let course of courseList"
           (onSelectionChange)="onCourseSelect($event,courseFormControl)">
            {{course.courseName}}
          </mat-option>
</mat-select>

component.ts

 onCourseSelect(event, form) {
    if(event.isUserInput) {
  let listCourseId =  [];
//data contains the total list
              data.map((val,ind) => {
                if(val.selected === true){
                  listCourseId.push(val.courseId)
                }
              });
          this.selectedCourseIds = listCourseId;

          this.courseFormControl.setValue(listCourseId);
}

在选择全部后抛出错误

core.js:15724错误RangeError:超出最大调用堆栈大小     在SafeSubscriber.push ../ node_modules / rxjs / _esm5 / internal / Subscriber.js.SafeSubscriber .__ tryOrUnsub(Subscriber.js:200)     在SafeSubscriber.push ../ node_modules / rxjs / _esm5 / internal / Subscriber.js.SafeSubscriber.next(Subscriber.js:130)     在Subscriber.push ../ node_modules / rxjs / _esm5 / internal / Subscriber.js.Subscriber._next(Subscriber.js:76)     在Subscriber.push ../ node_modules / rxjs / _esm5 / internal / Subscriber.js.Subscriber.next(Subscriber.js:53)     在EventEmitter.push ../ node_modules / rxjs / _esm5 / internal / Subject.js.Subject.next(Subject.js:47)     在EventEmitter.push ../ node_modules/@angular/core/fesm5/core.js.EventEmitter.emit(core.js:13499)     在MatOption.push ../ node_modules/@angular/material/esm5/core.es5.js.MatOption._emitSelectionChangeEvent(core.es5.js:2803)     在MatOption.push ../ node_modules/@angular/material/esm5/core.es5.js.MatOption.deselect(core.es5.js:2595)

0 个答案:

没有答案