【问题标题】:Country -> State-> City with angular-schema-form-dynamic-select国家 -> 州 -> 城市与角度模式形式动态选择
【发布时间】:2017-06-06 14:54:17
【问题描述】:

我目前正在使用 angular-schema-form-dynamic-select,我的要求是根据所选国家/地区选择州。我将数据存储在数据库中,例如 country -> state -> city。谁能帮我解决这个问题?

这是我的表格:

[
  {
    "key": "country",
    "type": "strapselect",
    "placeholder":"country",
    "options": {
      "httpGet": {
        "url": "/countries" 
      },
      "map": { "valueProperty": "readonlyProperties.id", "nameProperty":"name" }
    }
  },
  {
    "key": "state",
    "type": "strapselect",
    "placeholder":"state",
    "options": {            
      "httpGet": {
        "url": "/states"         
      },
      "map": { "valueProperty": "readonlyProperties.id", "nameProperty":"name" }
    }
  },
  {
    "key": "city",
    "type": "strapselect",
    "placeholder":"city",
    "options": {
      "httpGet": {
        "url": "/cities"
      },
      "map": { "valueProperty": "readonlyProperties.id", "nameProperty":"name" }
    }
  }
]

【问题讨论】:

  • 你能显示一些相关代码吗

标签: angularjs jsonschema angular-schema-form


【解决方案1】:

我认为这样的功能确实非常方便。也许你在 json 字符串中写了这样的东西:

{
    "type": "object",
    "properties": {
        "country": {
            "type": "string",
            "enumCallback": "getTitlesValues()"
        }
    }
}

在您的控制器中,您将定义该回调:

...
$scope.getTitlesValues = function () {
    return ['India','Australia', 'Germany', 'Sweden']
}
...

【讨论】:

    【解决方案2】:

    我认为这样的功能确实非常方便。 也许你在 json 字符串中写了这样的东西:

            {
            "type": "object",
            "properties": {
            "country": {
            "type": "string",
            "enumCallback": "getTitlesValues()"
               }
             }
           }
    

    在您的控制器中,您将定义该回调:

                 ...
                $scope.getTitlesValues = function () {
                return ['India','Australia', 'Germany', 'Sweden']
               }
                ...
    

    【讨论】:

      猜你喜欢
      • 2017-08-27
      • 2019-02-15
      • 1970-01-01
      • 1970-01-01
      • 2017-10-20
      • 2011-01-14
      • 1970-01-01
      • 2021-02-06
      • 1970-01-01
      相关资源
      最近更新 更多