简体   繁体   English

在Angular-Schema-Form中创建下拉列表不起作用

[英]Creating a dropdown in Angular-Schema-Form not working

I'm having some difficulty rendering a dropdown in ASF. 我在渲染ASF下拉菜单时遇到一些困难。 If I add an enum to the Schema it renders the dropdown with values one/two, not the "name" from the titleMap. 如果将一个枚举添加到Schema,它将以值一/二(而不是titleMap中的“名称”)呈现下拉列表。 This also doesn't allow to have a list of options served from the server. 这也不允许服务器提供选项列表。 Please help me find what I'm doing wrong. 请帮助我找出我在做错什么。

Thanks! 谢谢!

I have the following code in my Controller: 我的控制器中有以下代码:

    $scope.row = { choice: "one" };

    $scope.form = [
        {
            key: "choice",
            type: "select",
            titleMap: [
                { value: "one", name: "One" },
                { value: "two", name: "More..." }
            ]
        }
    ];

    $scope.schema = {
        type: "object",
        properties:{
            choice: {
                type: "string"
            }
        }
    };

And my HTML is: 我的HTML是:

    <form sf-schema="schema" sf-form="form" sf-model="row"></form>

You can change the properties type of $scope.schema 您可以更改$ scope.schema的属性类型

$scope.schema = {
    type: "object",
    properties:{
        choice: {
            type: "object"
        }
    }
};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM