AngularJS NG选项未呈现值 [英] AngularJS ng-options not rendering values

查看:149
本文介绍了AngularJS NG选项未呈现值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何能想出如何我可以呈现的选项列表值,

  $ scope.limits = [{值:'5',文本:Afficher 5杆页},
                        {值:'10',文本:Afficher 10页看齐},
                        {值:'15',文本:Afficher 15页看齐},
                        {值:'20',文本:Afficher 20页看齐'}
                     ];
<选择一个id =limitTypeNAME =限制NG-模式=限制NG选项=limit.value作为limit.text在限度的限度>< /选择> enregistrement比肩页

预期结果(在期待值=limit.value

 <选择NG选项=option.value作为option.text在限制选项NG模型=限制ID =limitType级=NG-质朴NG-有效>
    <期权价值=选择=选择&GT5; Afficher 5杆网页< /选项>
    <期权价值=10> Afficher 10杆网页< /选项>
    <期权价值=15> Afficher 15杆网页< /选项>
    <期权价值=20> Afficher 20杆网页< /选项>
< /选择>

结果:

 <选择NG选项=option.value作为option.text在限制选项NG模型=限制ID =limitType级=NG-质朴NG-有效>
    <期权价值=选择=选择&GT0; Afficher 5杆网页< /选项>
    <期权价值=1> Afficher 10杆网页< /选项>
    <期权价值=2> Afficher 15杆网页< /选项>
    <期权价值=3> Afficher 20杆网页< /选项>
< /选择>


解决方案

NG-选项指令不设置&LT属性;选项> 元素,它总是使用的序列。

使用 limit.value作为limit.text在限度的限度意思是:


  • <选项>的标签为 limit.text

  • 保存 limit.value 值到选择的 NG-模型

勾选此琴: http://jsfiddle.net/bmleite/k58Hw/

How can figured out how i can render the value of options list,

$scope.limits = [   {value: '5', text: 'Afficher 5 par page'}, 
                        {value: '10', text: 'Afficher 10 par page'}, 
                        {value: '15', text: 'Afficher 15 par page'}, 
                        {value: '20', text: 'Afficher 20 par page'}
                     ];


<select id="limitType" name="limit" ng-model="limit" ng-options="limit.value as limit.text for limit in limits"></select> enregistrement par page

Expected result (expecting in value="limit.value":

<select ng-options="option.value as option.text for option in limits" ng-model="limit" id="limitType" class="ng-pristine ng-valid">
    <option value="5" selected="selected">Afficher 5 par page</option>
    <option value="10">Afficher 10 par page</option>
    <option value="15">Afficher 15 par page</option>
    <option value="20">Afficher 20 par page</option>
</select>

Result:

<select ng-options="option.value as option.text for option in limits" ng-model="limit" id="limitType" class="ng-pristine ng-valid">
    <option value="0" selected="selected">Afficher 5 par page</option>
    <option value="1">Afficher 10 par page</option>
    <option value="2">Afficher 15 par page</option>
    <option value="3">Afficher 20 par page</option>
</select>

解决方案

The ng-options directive does not set the value attribute on the <options> elements, it always uses a sequence.

Using limit.value as limit.text for limit in limits means:

  • set the <option>'s label as limit.text
  • save the limit.value value into the select's ng-model

Check this fiddle: http://jsfiddle.net/bmleite/k58Hw/

这篇关于AngularJS NG选项未呈现值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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