双击按钮时,Boostrap模型显示两次

时间:2020-09-30 13:31:38

标签: javascript html angular

Htl代码在这里:

fun concatMap f = List.concat o List.map f
fun flatten (Elem x) = [x]
  | flatten (LList ts) = concatMap flatten ts

类型脚本代码在这里:

 <span class="fal fa-user green" style="cursor:pointer;"  (click)="openlotModal(lotTemplate,item);"
                  title="Add Chapter" *ngIf="edit==true"></span>

enter image description here

我不知道如何限制双击

1 个答案:

答案 0 :(得分:0)

我认为.subscribe中的可观察对象被触发了多次,这是正常现象。

尝试:

this.jobdefinitionservice.GetJobWorkFlowDefCount(jobObject).toPromise().then(res => {
            if (res.body[0] != null) {
                this.LoadChaptertypes();
                this.TablePagination = {
                    itemsPerPage: 10,
                    maxPages: 5,
                    fillLastPage: false
                };
                this.job = item;
                this.lotModalRef = this.modalService.show(template, this.configlot);
                const aa = document.getElementsByClassName('modal-content');
                aa[0].classList.remove('modal-content');
            } else {
                this.moveToJobDefinition(item);
                this.toastr.warning('Please complete job configuration, then proceed');

            }
        });

否则,您可能需要设置一个变量,并在显示模态时将其改回。

isOpening = false;

        ....
        if(this.isOpening) {
            return;
        }

        this.isOpening = true;
        this.jobdefinitionservice.GetJobWorkFlowDefCount(jobObject).toPromise().then(res => {
            this.isOpening = false;
            if (res.body[0] != null) {
                this.LoadChaptertypes();
                this.TablePagination = {
                    itemsPerPage: 10,
                    maxPages: 5,
                    fillLastPage: false
                };
                this.job = item;
                this.lotModalRef = this.modalService.show(template, this.configlot);
                const aa = document.getElementsByClassName('modal-content');
                aa[0].classList.remove('modal-content');
            } else {
                this.moveToJobDefinition(item);
                this.toastr.warning('Please complete job configuration, then proceed');

            }
        });