升序" ng-options"不工作

时间:2014-04-28 13:54:46

标签: javascript angularjs angularjs-filter

我有以下代码(Ctrl):

$scope.dummie = 8; // Default value
$scope.dummie_opts = $filter('range')([],24);
// [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]

Filters.js: @see AngularJS For Loop with Numbers & Ranges

AppSalud.filter('range', function() {
    return function(input, total) {
        total = parseInt(total);
        for (var i=1; i<=total; i++) input.push(i);
        return input;
    };
});

查看:

<select name="dummie" ng-model="dummie" ng-options="v as v for (k,v) in dummie_opts">

结果:

<option value="0">1</option>
<option value="1">2</option>
<option value="10">11</option>
<option value="11">12</option>
<option value="12">13</option>
<option value="13">14</option>
<option value="14">15</option>
<option value="15">16</option>
<option value="16">17</option>
<option value="17">18</option>
<option value="18">19</option>
<option value="19">20</option>
<option value="2">3</option>
<option value="20">21</option>
<option value="21">22</option>
<option value="22">23</option>
<option value="23">24</option>
<option value="3">4</option>
<option value="4">5</option>
<option value="5">6</option>
<option value="6">7</option>
<option value="7">8</option>
<option value="8">9</option>
<option value="9">10</option>

我不在标签&#34;选项&#34;中使用循环。因为我没有采用默认值。

0 个答案:

没有答案