【发布时间】:2018-03-06 23:21:37
【问题描述】:
由于我对 typescript 还很陌生,所以我想扩展一下前段时间发布的关于 typescript 中的通配符的问题。 Here is the original question.
我的 Angular 2/Web.API/MVC 应用程序正在我的数据库中使用递归搜索,以在 3 个不同的列中返回填充过滤器模式的不同类型列表。当用户在选择列表之一中选择一个值时, 我想用与第一个选择列表匹配的所有可用值填充其他 2 个选择列表。但目前,“未定义”正在从组件传递到控制器,导致它查找空值,而不是所有值。
所以这是我的组件中的强制性代码:
我的更新事件:
UpdateAllLookups(event) {
this.allLookups = [];
if ("year" == event.srcElement.id) {
this.corrCodesfilter.rgln_Year = this.getSelectedItem("year").value
} else { this.corrCodesfilter.rgln_Year = this.corrCodesfilter.rgln_Year; }
if ("regType" == event.srcElement.id) {
this.corrCodesfilter.rgln_type_code = this.getSelectedItem("regType").value;
} else { this.corrCodesfilter.rgln_type_code = this.corrCodesfilter.rgln_type_code;}
if("valdtnCode"== event.srcElement.id){
this.corrCodesfilter.valdtn_code = this.getSelectedItem("valdtnCode").value;
} else { this.corrCodesfilter.valdtn_code = this.corrCodesfilter.valdtn_code;}
this._corrCodeService.getLookupsUpdate(Global.BASE_CORRECTION_CODE_ENDPOINT + "GetLookupsUpdate?", this.corrCodesfilter)
.subscribe(allLookups => {
this.allLookups = allLookups;
this.getYearLookups();
this.getRegLookups();
this.indLoading = false;
}, error => this.msg = <any>error);
}
如果我在 c# 中工作,我会通过:
if(String.IsNullOrEmpty(this.corrCodesFilter.rgln_Year)){
this.corrCodesFilter.rgln_Year = *;}
如果值未定义,我可以做些什么来传递通配符?我无法使用未定义的值来访问我的控制器,否则我会在那里完成。非常感谢您提供的任何帮助。
【问题讨论】:
-
不确定我是否理解正确,但该 C# 表达式的等效项是:this.corrCodesFilter.rgln_Year = this.corrCodesFilter.rgln_Year || '*'
标签: typescript wildcard angular2-forms