我不知道我对这个概念的理解是否错误,但几个小时的搜索并没有产生任何结果。
我想根据用户从下拉列表中选择的“类型”动态加载表单的字段。这通过 Angular 绑定到变量“currentType”。那部分有效。
currentType = //whatever the user chose. Will evaluate to either "category1" or "category2"
currentFields = {}
fields = {
'category1': {
propertyInfo {
'label1'
'label2'
'label3'
'label4'
'category2': {
propertyInfo {
'label5'
'label6'
'label7'
'label8'
Run Code Online (Sandbox Code Playgroud)
我想要发生的是,当选择类型时,将加载字段。所以:
currentFields = field."currentType".propertyInfo
Run Code Online (Sandbox Code Playgroud)
我不知道如何将该变量插入到对象路径中。我不断收到有关字段没有属性“currentType”的错误。