我使用下面的代码进行绑定重复下拉并选择存储在数据库中的下拉值
Object oMissing = System.Reflection.Missing.Value;
Object oTemplatePath = "C:\\MyTemplate.dotx";
Application wordApp = new Application();
Document wordDoc = new Document();
wordDoc = wordApp.Documents.Add(ref oTemplatePath, ref oMissing, ref oMissing, ref oMissing);
foreach (Microsoft.Office.Interop.Word.Field myMergeField in wordDoc.Fields)
{
Range rngFieldCode = myMergeField.Code;
String fieldText = rngFieldCode.Text;
if (fieldText.StartsWith(" MERGEFIELD"))
{
Int32 endMerge = fieldText.IndexOf("\\");
Int32 fieldNameLength = fieldText.Length - endMerge;
String fieldName = fieldText.Substring(11, endMerge - 11);
fieldName = fieldName.Trim();
if (fieldName == "Name")
{
myMergeField.Select();
wordApp.Selection.TypeText(txtSponsorResp.Text.ToString());
}
//other fields .....
}
}
wordDoc.SaveAs("myFile.doc");
wordApp.Documents.Open("myFile.doc");
wordApp.Application.Quit();
使用ngModel选择下拉值不起作用
module_defaultselection 具有适当的值,可在下拉选项中找到。
答案 0 :(得分:3)
在选择下拉列表中使用[ngModelOptions] =“{standalone:true}”参考下面的代码
<div class="form-group row" *ngFor="let option of roles let x = index">
<div class="col-8">
<select [disabled]="adminstratorStatus=='true'" class="form-control custom-select col-12" id="company_info_management" required
[(ngModel)]="roles[x].module_defaultselection" name="company_info_management"
#company_info_management="ngModel" [ngModelOptions]="{standalone: true}">
<option value="">--select company--</option>
<option *ngFor="let myRole of option.module_role;" value="{{myRole.module_role}}"> {{myRole.module_role_description | translate }} </option>
</select>
</div>
</div>