【发布时间】:2015-06-18 23:08:15
【问题描述】:
我不知道我是否对这个概念的理解有误,但数小时的搜索并没有产生任何结果。
我想根据用户从下拉列表中选择的“类型”为表单动态加载字段。这通过角度绑定到变量“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'
我想要发生的是,选择类型时,将加载字段。所以:
currentFields = field."currentType".propertyInfo
我不知道如何将该变量插入到对象路径中。我不断收到关于没有属性“currentType”的字段的错误。
【问题讨论】:
标签: javascript angularjs variables object