LumX lx-select不更新ng-model

时间:2014-12-25 22:12:10

标签: javascript angularjs material-design angular-material

我最近开始使用LumX框架,我试图使用他们的Selects指令here,但我不清楚他们的文档。这是我到目前为止所得到的:

        <lx-select ng-model="selectedPriority" placeholder="Priority" choices="priorities">
            <lx-select-selected>
                {{ $selected.name }}
            </lx-select-selected>

            <lx-select-choices>
                {{ $choice.name }}
            </lx-select-choices>
        </lx-select>

这就是我如何定义优先级(在包含lx-select的div的控制器内)

$scope.priorities = [
    { name: 'Urgent',               id: 1 },
    { name: 'Very important',       id: 2 },
    { name: 'Not important',        id: 3 },
    { name: 'None',                 id: 4 }
];

这给了我一个可供选择的列表,但selectedPriority模型永远不会更新,因此每当我尝试使用该值时,它总是未定义的。我甚至无法运行他们在文档页面中提供的示例,但我不确定我缺少什么。

2 个答案:

答案 0 :(得分:2)

以这种方式初始化selectedPriority变量:

$scope.selects = {
    selectedPriority: undefined,
};
似乎可以解决问题。我试过没有在数组中声明selectedPriority但据我所知,这是模型正确更新的唯一方法。

答案 1 :(得分:0)

检查您的角度版本,看它是否符合您的lumX版本的最低要求。

例如,对于lumX版本0.3.24和角度版本1.2.28的匹配将产生您遇到的问题(模型不会更新),就我实验而言。

相关问题