纳克模型数据不所选纳克选项结合 [英] ng-model data is not binding for selected ng-option

查看:128
本文介绍了纳克模型数据不所选纳克选项结合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HTML

<select
    ng-model="selected1"
    ng-options="item.Name as item.Name for item in jobLineClassFSC"
    class="gridinputs">
</select>
<select
    ng-model="selectedJobLineTypeFSC"
    ng-options="item.Name as item.Name for item in jobLineTypeFSC">
</select>

<select
    ng-model="selectedJobLineSubTypeFSC"
    ng-options="item.Name as item.Name for item in jobLineSubTypeFSC">

我得到的结果并正确显示;但选择列表是没有得到绑定到NG-模式,我不知道为什么。我实现在我的项目另一个地方它的工作在那里一样。任何人都可以请让我知道该怎么做。任何帮助将是非常美联社preciated。

I'm getting the result and display it properly; but the selected list is not getting bound to the ng-model and I don't know why. I implemented the same in another place in my project it's working over there. Can anyone please let me know how to do that. Any help will be really appreciated.

推荐答案

我的猜测是你的选择标记在不同范围控制器。因此, NG-模型店选择了错误的范围内的值。

My guess would be your select tags are in different scope to your controller. So the ng-model store selected values inside the wrong scope.

要避免这种情况最好的做法是用点符号如 model.selectedJobLineTypeFSC

To avoid this the best practice is to use the dot notation like model.selectedJobLineTypeFSC:

<select ng-model="model.selectedJobLineTypeFSC"
        ng-options="item.Name as item.Name for item in jobLineTypeFSC"></select>

并在控制器检查 $ scope.model.selectedJobLineTypeFSC 代替。

这篇关于纳克模型数据不所选纳克选项结合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆