角下拉级Excel帖子
我想创建一个选择下拉列表,当用户选择将发送给后端控制器的值时。到目前为止,这是我的代码
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在您的垫子选择标签中,添加
(selectionChange)=“ OnSelectedTemplateChange($ event)”
然后在组件中,创建一种方法,
一旦有工作,您应该能够将该方法更改为传递给您的服务。
Within your mat-select tag, add
(selectionChange)="onSelectedTemplateChange($event)"
Then in your component, create a method of
Once you have that working you should be able to change that method to instead pass to your service.