Select 下拉菜单不是通过 ng-repeat 和 ng-options 生成的

Select dropdown not generated via ng-repeat and ng-options

下面的两个下拉列表不会生成年份数组。我还需要将年份从早到晚排序,但 orderBy 过滤器不起作用。

 <select title="- Select a period -" class="period " id="reportingPeriods">
        <option ng-repeat="reportingPeriod for reportingPeriod in reportingPeriods">{{reportingPeriod}}</option>
      </select>
      <br />
      <select title="- Select a period -" class="period selectpicker" id="" 
      ng-options="reportingPeriod for reportingPeriod in reportingPeriods | orderBy: '-reportingPeriod' ">
      </select>

这是我的 javascript

(function(angular) {
  'use strict';
angular.module('ngrepeatSelect', [])
  .controller('ExampleController', ['$scope', function($scope) {
    console.clear();
    $scope.data = {
     repeatSelect: null,
     availableOptions: [
       {id: '1', name: 'Option A'},
       {id: '2', name: 'Option B'},
       {id: '3', name: 'Option C'}
     ],
    };

    $scope.reportingPeriods = [1999, 2011, 2000, 1988, 1995, 2014];
 }]);
})(window.angular);

这是我的plunkr

您在 select 选项中对 ng-options 和 ng-repeat 使用了错误的语法。固定在这里 - http://plnkr.co/edit/oPI9kvQFuYJmrEwBDnWv?p=preview

您还需要将 ng-models 分配给 select 才能工作(正如@AvijitGupta 在上面的评论中提到的)

<select ng-model="period" title="- Select a period -" class="period " id="reportingPeriods">
    <option ng-repeat="reportingPeriod in reportingPeriods">{{reportingPeriod}}</option>
  </select>
  <br />
  <select ng-model="preiod" title="- Select a period -" class="period selectpicker" id="" 
  ng-options="reportingPeriod for reportingPeriod in reportingPeriods | orderBy: '-' ">
  </select>