国家 - >状态 - >具有角度图式形式动态选择的城市

时间:2016-12-01 09:50:52

标签: angularjs jsonschema angular-schema-form

我目前正在使用angular-schema-form-dynamic-select,我的要求是根据所选国家选择状态。我将数据存储在数据库中,如 country - >国家 - >城市即可。有谁可以帮我这个?

这是我的表格:

[
  {
    "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" }
    }
  }
]

2 个答案:

答案 0 :(得分:0)

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

class BaseMethods(object):
    def __init__(self, related):
         self.related = related

    def __getattr__(self, attr):
        return getattr(self.related, attr)

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

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

答案 1 :(得分:-1)

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

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

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

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