AngularJs:如何根据基于用户的下拉选择为ng模型赋值
我尝试使用下拉选择并使用“Selected”值将搜索框的模型指定给以下值之一:AngularJs:如何根据基于用户的下拉选择为ng模型赋值,angularjs,Angularjs,我尝试使用下拉选择并使用“Selected”值将搜索框的模型指定给以下值之一: ng-model=searchText.$ (For search across Any of the 3 fields) ng-model=searchText.name (For search only on name field) ng-model=searchText.age (For search only on age field) ng-model=searchText.gender (For se
ng-model=searchText.$ (For search across Any of the 3 fields)
ng-model=searchText.name (For search only on name field)
ng-model=searchText.age (For search only on age field)
ng-model=searchText.gender (For search only on gender field)
搜索框的上述ng模型随后将用于过滤对象的JavaScript数组
尽管谷歌搜索了3天多,并尝试了各种“技巧”,如使用
"ng-model=searchText.{{filterTypeSelectModel}}"
我无法根据基于用户的下拉过滤器选择设置ng模型值
现在,只有在编写代码时硬编码ng model的值时,过滤器才能工作。我无法在运行时或根据用户选择的下拉筛选器分配ng模型
我失败的尝试将有助于进一步解释我试图实现的目标:
这是最新的小提琴不错的答案!这看起来正是OP想要的!谢谢你!解决了这个问题。然而,我需要整理我的代码,因为后续的过滤会记住以前的过滤列表,因此使用该子集作为“源”列表。