如何在提交时从 ngx-modal 检索数据 angular 5

How to retrieve data from ngx-modal on submit angular 5

我正在使用 ngx-modal 创建对话框,下面是 html

中的代码
<button (click)="myModal.open()">Click Me</button>

<modal #myModal cancelButtonLabel="Cancel All 
[(ngModel)]="rfin" submitButtonLabel="submit" 
(onSubmit)="callSubmit()">

<modal-content >
<mat-card>
<mat-card-content   >
<h2 class="example-h2">Select Emp</h2><br>

<section class="example-section" *ngFor="let ep of emp" >

<ng-template>
<mat-checkbox [(ngModel)]="ep.checked">{{ep.name}}</mat-checkbox>
</ng-template>

</section>

</mat-card>
</modal-content>
</modal>

这是我的 ts 文件中的代码

callSubmit(val)
{
Console.log(val);
}

但我越来越不确定。 请推荐

添加了组件代码,这里我尝试访问控制台中的数据。

    import { Component,  Input, OnInit, Inject } from '@angular/core';
    import { ConfigService } from '../services/config.service';
    import { FormControl } from '@angular/forms';

    @Component({
    selector: 'app-emp,
    templateUrl: './emp.html',
    styleUrls: ['./emp.css'],
    })
    export class EmpComponent {
    rfin:any;
    empdata:any=[];
    emp:any=[];

    constructor(private configs: ConfigService){}

    callSubmit() 
    {
    Console.log(this.rfin);
    }

//getEmp 是从 api
获取值的服务调用 getEmp() {

this.configs.doEmp().subscribe(

data => {this.empdata = data['emp'];

this.emp = this.empdata.map(o => {
return {

name: o.name, isData: o.isData, checked: false

};

});

},

err => console.error(err),         
() => console.log('done loading emp'));

}

 ngOnInit() {
        this.getEmp();
    }
}

还更新了提交时

我不确定您为什么在模型弹出部分使用 [(ngModel)]="rfin"。但是无论如何你都可以尝试这种替代方法来 read/write 模型对象。

您不需要将模型对象传递给 onSubmit 方法。您可以直接在方法本身中使用。

(onSubmit)="callSubmit()"

在代码中

callSubmit()
{
Console.log(this.rfin);
}

注意:确保您在组件中声明了这个模型rfin对象class