角下拉级Excel帖子

发布于 2025-02-13 10:53:06 字数 1188 浏览 1 评论 0原文

我想创建一个选择下拉列表,当用户选择将发送给后端控制器的值时。到目前为止,这是我的代码

html

 <mat-form-field appearance="fill" class="dropDown1">
        <mat-select [(ngModel)]="selectedTemplate">
             <mat-option *ngFor="let items of filter" [value]="items.value">
                {{items.value}}
             </mat-option>
       </mat-select>
 </mat-form-field> 

.ts

 selectedTemplate(trigger: MatSelectChange){
    this.filter = trigger.value;
    this.TemplateName = trigger.value;
  }




onUpload(){
    let formData = new FormData();
    formData.set("file",this.file)
    formData.set("TemplateName",this.TemplateName)
    console.log(this.TemplateName);

    this.http.post(this.appsetting.baseURL + 'MyFiles/UploadExcelFile',formData) 
    .subscribe((response)=>{
      console.log(response);
      Swal.fire({
        title:'Uploaded Successfully',
        icon: 'success',
        heightAuto: false,
        width: 400
      }).then((result)=>{
        if (result.isConfirmed){
          this.refreshPage();
        }
      })
    })
  }

I want to create a selection dropdown that when the user select a value it will send to the backend controller. This is my code so far anyone could help

HTML

 <mat-form-field appearance="fill" class="dropDown1">
        <mat-select [(ngModel)]="selectedTemplate">
             <mat-option *ngFor="let items of filter" [value]="items.value">
                {{items.value}}
             </mat-option>
       </mat-select>
 </mat-form-field> 

.TS

 selectedTemplate(trigger: MatSelectChange){
    this.filter = trigger.value;
    this.TemplateName = trigger.value;
  }




onUpload(){
    let formData = new FormData();
    formData.set("file",this.file)
    formData.set("TemplateName",this.TemplateName)
    console.log(this.TemplateName);

    this.http.post(this.appsetting.baseURL + 'MyFiles/UploadExcelFile',formData) 
    .subscribe((response)=>{
      console.log(response);
      Swal.fire({
        title:'Uploaded Successfully',
        icon: 'success',
        heightAuto: false,
        width: 400
      }).then((result)=>{
        if (result.isConfirmed){
          this.refreshPage();
        }
      })
    })
  }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

牵你的手,一向走下去 2025-02-20 10:53:06

在您的垫子选择标签中,添加(selectionChange)=“ OnSelectedTemplateChange($ event)”

然后在组件中,创建一种方法,

onSelectedTemplateChange(template) {
  console.log({template});
}

一旦有工作,您应该能够将该方法更改为传递给您的服务。

Within your mat-select tag, add (selectionChange)="onSelectedTemplateChange($event)"

Then in your component, create a method of

onSelectedTemplateChange(template) {
  console.log({template});
}

Once you have that working you should be able to change that method to instead pass to your service.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文