简体   繁体   English

AngularJS-从ng-option返回数据

[英]Angularjs - returning data from a ng-option

I'm trying to fetch some data from my database and it works fine in my ng-option, but I can't grab the output and show it to the user with the selectCenter.land 我正在尝试从数据库中获取一些数据,并且在ng-option中可以正常工作,但是我无法获取输出并通过selectCenter.land将其显示给用户

This is my ng-option 这是我的ng选项

            <select
            ng-model="selectCenter"
            ng-options="center.center_navn for center in centre | filter:searchCentre"
            ng-change="findCenter(114)"
            multiple class="form-control input-lg">
        </select>
        You have chosen:
        {{ selectCenter }}

my output in the console looks fine like this: [Object, Object, Object, Object] where I have 我在控制台中的输出看起来像这样:[Object,Object,Object,Object]

[0] [0]
[1] etc. [1]等

and on the "you have Chosen" it shows 并在“您已选择”上显示

 [{"id":"122","shopID":"200","land":"denmark"}]

Can some one see what I'm doing wrong? 有人可以看到我在做什么吗?

According to your piece of code: 根据您的代码段:

  1. correct option name for ngOptions . ngOptions的正确选项名称。 I didn't see center_navn is an attribute of your center object. 我没有看到center_navn是您的center对象的属性。
  2. working filter. 工作过滤器。

Please provide more details about what the scope variable centre is. 请提供有关范围变量centre是什么的更多详细信息。

Here's working plunker: http://plnkr.co/edit/Q8jhdJltlh14oBBLeHJ9?p=preview 这里的工作人员: http ://plnkr.co/edit/Q8jhdJltlh14oBBLeHJ9?p=preview

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

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