Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 根据另一个下拉列表的选定值生成下拉列表选项_Javascript_Angularjs - Fatal编程技术网

Javascript 根据另一个下拉列表的选定值生成下拉列表选项

Javascript 根据另一个下拉列表的选定值生成下拉列表选项,javascript,angularjs,Javascript,Angularjs,我用angularJS的ng选项创建了两个下拉列表开放时间和关闭时间。下拉选项由相同的数组$scope.availableTimes <head lang="en"> <meta charset="utf-8" /> <title>Custom Plunker</title> <script data-require="moment.js@*" data-semver="2.14.1" src="h

我用angularJS的ng选项创建了两个下拉列表开放时间关闭时间。下拉选项由相同的数组
$scope.availableTimes

    <head lang="en">
      <meta charset="utf-8" />
      <title>Custom Plunker</title>
      <script data-require="moment.js@*" data-semver="2.14.1" src="https://npmcdn.com/moment@2.14.1"></script>
      <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.js"></script>
      <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.0/css/bootstrap-combined.min.css" rel="stylesheet" />
      <link rel="stylesheet" href="style.css" />
      <script>
        document.write('<base href="' + document.location + '" />');
      </script>
      <script src="pagination.js"></script>
      <script src="app.js"></script>
    </head>

    <body ng-controller="MainCtrl">
      <div class="row">
        <div class="col-md-6">
          <div class="form-group">
            <label for="exampleFormControlSelect1">Opening Hours</label>
            <select class="form-control" data-ng-options="time.display for time in availableTimes" data-ng-model="selectedFromTime" ng-change="automaticallySelectClosingTime(selectedFromTime.msValue)">
            </select>
          </div>
        </div>
        <div class="col-md-6">
          <div class="form-group">
            <label for="exampleFormControlSelect1">Closing Hours</label>
             <select class="form-control" data-ng-options="time.display for time in closingTimes" data-ng-model="selectedToTime">
            </select>
          </div>
        </div>
      </div>
    </body>

    </html>

index.html

var app = angular.module('angularjs-starter', []);

app.controller('MainCtrl', function($scope) {
  $scope.availableTimes = [];
  $scope.closingTimes = [];
  $scope.availableTimes.push({
    'msValue': 0,
    'display': '12:00 Morning'
  });
  for (var msValue = 900000; msValue <= 85500000; msValue += 900000) { // 90.000ms = 15 min, 85.500.000ms = 11:45PM
    $scope.availableTimes.push({
      'msValue': msValue,
      'display': moment(msValue).utc().format("h:mm A")
    })
  }
  var dayMS = 86400000 - 1;
  $scope.availableTimes.push({
    'msValue': dayMS,
    'display': '12:00 Midnight'
  });
  $scope.closingTimes = $scope.availableTimes;
  console.log($scope.availableTimes);

  $scope.automaticallySelectClosingTime = function(msValue) {
    $scope.closingTimes = $scope.availableTimes;
    var remainingTimings = [];
    var index = $scope.closingTimes.map(function(obj){return obj.msValue;}).indexOf(msValue);
    index = (index === $scope.availableTimes.length-1) ? 1 : index+1;
    $scope.closingTimes = $scope.closingTimes.slice(index,$scope.availableTimes.length);
    if(msValue !== dayMS) {
      remainingTimings = $scope.availableTimes.slice(1,index -1);
    }
    $scope.closingTimes = $scope.closingTimes.concat(remainingTimings);
    $scope.selectedToTime = $scope.closingTimes[0];
  }
});
以下是HTML代码:

<div class="row">
    <div class="col-md-6">
      <div class="form-group">
        <label for="exampleFormControlSelect1">Opening </label>
        <select class="form-control" data-ng-options="time.display for time in availableTimes" data-ng-model="selectedFromTime">
        </select>
      </div>
    </div>
    <div class="col-md-6">
      <div class="form-group">
        <label for="exampleFormControlSelect1">Closing</label>
         <select class="form-control" data-ng-options="time.display for time in availableTimes" data-ng-model="selectedToTime">
        </select>
      </div>
    </div>
  </div>
    <head lang="en">
      <meta charset="utf-8" />
      <title>Custom Plunker</title>
      <script data-require="moment.js@*" data-semver="2.14.1" src="https://npmcdn.com/moment@2.14.1"></script>
      <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.js"></script>
      <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.0/css/bootstrap-combined.min.css" rel="stylesheet" />
      <link rel="stylesheet" href="style.css" />
      <script>
        document.write('<base href="' + document.location + '" />');
      </script>
      <script src="pagination.js"></script>
      <script src="app.js"></script>
    </head>

    <body ng-controller="MainCtrl">
      <div class="row">
        <div class="col-md-6">
          <div class="form-group">
            <label for="exampleFormControlSelect1">Opening Hours</label>
            <select class="form-control" data-ng-options="time.display for time in availableTimes" data-ng-model="selectedFromTime" ng-change="automaticallySelectClosingTime(selectedFromTime.msValue)">
            </select>
          </div>
        </div>
        <div class="col-md-6">
          <div class="form-group">
            <label for="exampleFormControlSelect1">Closing Hours</label>
             <select class="form-control" data-ng-options="time.display for time in closingTimes" data-ng-model="selectedToTime">
            </select>
          </div>
        </div>
      </div>
    </body>

    </html>

index.html

var app = angular.module('angularjs-starter', []);

app.controller('MainCtrl', function($scope) {
  $scope.availableTimes = [];
  $scope.closingTimes = [];
  $scope.availableTimes.push({
    'msValue': 0,
    'display': '12:00 Morning'
  });
  for (var msValue = 900000; msValue <= 85500000; msValue += 900000) { // 90.000ms = 15 min, 85.500.000ms = 11:45PM
    $scope.availableTimes.push({
      'msValue': msValue,
      'display': moment(msValue).utc().format("h:mm A")
    })
  }
  var dayMS = 86400000 - 1;
  $scope.availableTimes.push({
    'msValue': dayMS,
    'display': '12:00 Midnight'
  });
  $scope.closingTimes = $scope.availableTimes;
  console.log($scope.availableTimes);

  $scope.automaticallySelectClosingTime = function(msValue) {
    $scope.closingTimes = $scope.availableTimes;
    var remainingTimings = [];
    var index = $scope.closingTimes.map(function(obj){return obj.msValue;}).indexOf(msValue);
    index = (index === $scope.availableTimes.length-1) ? 1 : index+1;
    $scope.closingTimes = $scope.closingTimes.slice(index,$scope.availableTimes.length);
    if(msValue !== dayMS) {
      remainingTimings = $scope.availableTimes.slice(1,index -1);
    }
    $scope.closingTimes = $scope.closingTimes.concat(remainingTimings);
    $scope.selectedToTime = $scope.closingTimes[0];
  }
});

开放
结束
下面是AngularJS脚本

var app = angular.module('angularjs-starter', []);

app.controller('MainCtrl', function($scope) {
  $scope.availableTimes = [];
  $scope.availableTimes.push({
    'msValue': 0,
    'display': '12:00 Morning'
  });
  for (var msValue = 900000; msValue <= 85500000; msValue += 900000) { // 90.000ms = 15 min, 85.500.000ms = 11:45PM
    $scope.availableTimes.push({
      'msValue': msValue,
      'display': moment(msValue).utc().format("h:mm A")
    })
  }
  var dayMS = 86400000 - 1;
  $scope.availableTimes.push({
    'msValue': dayMS,
    'display': '12:00 Midnight'
  });

  console.log($scope.availableTimes);
});
    <head lang="en">
      <meta charset="utf-8" />
      <title>Custom Plunker</title>
      <script data-require="moment.js@*" data-semver="2.14.1" src="https://npmcdn.com/moment@2.14.1"></script>
      <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.js"></script>
      <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.0/css/bootstrap-combined.min.css" rel="stylesheet" />
      <link rel="stylesheet" href="style.css" />
      <script>
        document.write('<base href="' + document.location + '" />');
      </script>
      <script src="pagination.js"></script>
      <script src="app.js"></script>
    </head>

    <body ng-controller="MainCtrl">
      <div class="row">
        <div class="col-md-6">
          <div class="form-group">
            <label for="exampleFormControlSelect1">Opening Hours</label>
            <select class="form-control" data-ng-options="time.display for time in availableTimes" data-ng-model="selectedFromTime" ng-change="automaticallySelectClosingTime(selectedFromTime.msValue)">
            </select>
          </div>
        </div>
        <div class="col-md-6">
          <div class="form-group">
            <label for="exampleFormControlSelect1">Closing Hours</label>
             <select class="form-control" data-ng-options="time.display for time in closingTimes" data-ng-model="selectedToTime">
            </select>
          </div>
        </div>
      </div>
    </body>

    </html>

index.html

var app = angular.module('angularjs-starter', []);

app.controller('MainCtrl', function($scope) {
  $scope.availableTimes = [];
  $scope.closingTimes = [];
  $scope.availableTimes.push({
    'msValue': 0,
    'display': '12:00 Morning'
  });
  for (var msValue = 900000; msValue <= 85500000; msValue += 900000) { // 90.000ms = 15 min, 85.500.000ms = 11:45PM
    $scope.availableTimes.push({
      'msValue': msValue,
      'display': moment(msValue).utc().format("h:mm A")
    })
  }
  var dayMS = 86400000 - 1;
  $scope.availableTimes.push({
    'msValue': dayMS,
    'display': '12:00 Midnight'
  });
  $scope.closingTimes = $scope.availableTimes;
  console.log($scope.availableTimes);

  $scope.automaticallySelectClosingTime = function(msValue) {
    $scope.closingTimes = $scope.availableTimes;
    var remainingTimings = [];
    var index = $scope.closingTimes.map(function(obj){return obj.msValue;}).indexOf(msValue);
    index = (index === $scope.availableTimes.length-1) ? 1 : index+1;
    $scope.closingTimes = $scope.closingTimes.slice(index,$scope.availableTimes.length);
    if(msValue !== dayMS) {
      remainingTimings = $scope.availableTimes.slice(1,index -1);
    }
    $scope.closingTimes = $scope.closingTimes.concat(remainingTimings);
    $scope.selectedToTime = $scope.closingTimes[0];
  }
});
var-app=angular.module('angularjs-starter',[]);
应用程序控制器('MainCtrl',函数($scope){
$scope.availableTimes=[];
$scope.availableTimes.push({
“msValue”:0,
“显示”:“上午12:00”
});

对于(var msValue=900000;msValue我已经更新了您的代码

    <head lang="en">
      <meta charset="utf-8" />
      <title>Custom Plunker</title>
      <script data-require="moment.js@*" data-semver="2.14.1" src="https://npmcdn.com/moment@2.14.1"></script>
      <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.js"></script>
      <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.0/css/bootstrap-combined.min.css" rel="stylesheet" />
      <link rel="stylesheet" href="style.css" />
      <script>
        document.write('<base href="' + document.location + '" />');
      </script>
      <script src="pagination.js"></script>
      <script src="app.js"></script>
    </head>

    <body ng-controller="MainCtrl">
      <div class="row">
        <div class="col-md-6">
          <div class="form-group">
            <label for="exampleFormControlSelect1">Opening Hours</label>
            <select class="form-control" data-ng-options="time.display for time in availableTimes" data-ng-model="selectedFromTime" ng-change="automaticallySelectClosingTime(selectedFromTime.msValue)">
            </select>
          </div>
        </div>
        <div class="col-md-6">
          <div class="form-group">
            <label for="exampleFormControlSelect1">Closing Hours</label>
             <select class="form-control" data-ng-options="time.display for time in closingTimes" data-ng-model="selectedToTime">
            </select>
          </div>
        </div>
      </div>
    </body>

    </html>

index.html

var app = angular.module('angularjs-starter', []);

app.controller('MainCtrl', function($scope) {
  $scope.availableTimes = [];
  $scope.closingTimes = [];
  $scope.availableTimes.push({
    'msValue': 0,
    'display': '12:00 Morning'
  });
  for (var msValue = 900000; msValue <= 85500000; msValue += 900000) { // 90.000ms = 15 min, 85.500.000ms = 11:45PM
    $scope.availableTimes.push({
      'msValue': msValue,
      'display': moment(msValue).utc().format("h:mm A")
    })
  }
  var dayMS = 86400000 - 1;
  $scope.availableTimes.push({
    'msValue': dayMS,
    'display': '12:00 Midnight'
  });
  $scope.closingTimes = $scope.availableTimes;
  console.log($scope.availableTimes);

  $scope.automaticallySelectClosingTime = function(msValue) {
    $scope.closingTimes = $scope.availableTimes;
    var remainingTimings = [];
    var index = $scope.closingTimes.map(function(obj){return obj.msValue;}).indexOf(msValue);
    index = (index === $scope.availableTimes.length-1) ? 1 : index+1;
    $scope.closingTimes = $scope.closingTimes.slice(index,$scope.availableTimes.length);
    if(msValue !== dayMS) {
      remainingTimings = $scope.availableTimes.slice(1,index -1);
    }
    $scope.closingTimes = $scope.closingTimes.concat(remainingTimings);
    $scope.selectedToTime = $scope.closingTimes[0];
  }
});
使用以下文件:

    <head lang="en">
      <meta charset="utf-8" />
      <title>Custom Plunker</title>
      <script data-require="moment.js@*" data-semver="2.14.1" src="https://npmcdn.com/moment@2.14.1"></script>
      <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.js"></script>
      <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.0/css/bootstrap-combined.min.css" rel="stylesheet" />
      <link rel="stylesheet" href="style.css" />
      <script>
        document.write('<base href="' + document.location + '" />');
      </script>
      <script src="pagination.js"></script>
      <script src="app.js"></script>
    </head>

    <body ng-controller="MainCtrl">
      <div class="row">
        <div class="col-md-6">
          <div class="form-group">
            <label for="exampleFormControlSelect1">Opening Hours</label>
            <select class="form-control" data-ng-options="time.display for time in availableTimes" data-ng-model="selectedFromTime" ng-change="automaticallySelectClosingTime(selectedFromTime.msValue)">
            </select>
          </div>
        </div>
        <div class="col-md-6">
          <div class="form-group">
            <label for="exampleFormControlSelect1">Closing Hours</label>
             <select class="form-control" data-ng-options="time.display for time in closingTimes" data-ng-model="selectedToTime">
            </select>
          </div>
        </div>
      </div>
    </body>

    </html>

index.html

var app = angular.module('angularjs-starter', []);

app.controller('MainCtrl', function($scope) {
  $scope.availableTimes = [];
  $scope.closingTimes = [];
  $scope.availableTimes.push({
    'msValue': 0,
    'display': '12:00 Morning'
  });
  for (var msValue = 900000; msValue <= 85500000; msValue += 900000) { // 90.000ms = 15 min, 85.500.000ms = 11:45PM
    $scope.availableTimes.push({
      'msValue': msValue,
      'display': moment(msValue).utc().format("h:mm A")
    })
  }
  var dayMS = 86400000 - 1;
  $scope.availableTimes.push({
    'msValue': dayMS,
    'display': '12:00 Midnight'
  });
  $scope.closingTimes = $scope.availableTimes;
  console.log($scope.availableTimes);

  $scope.automaticallySelectClosingTime = function(msValue) {
    $scope.closingTimes = $scope.availableTimes;
    var remainingTimings = [];
    var index = $scope.closingTimes.map(function(obj){return obj.msValue;}).indexOf(msValue);
    index = (index === $scope.availableTimes.length-1) ? 1 : index+1;
    $scope.closingTimes = $scope.closingTimes.slice(index,$scope.availableTimes.length);
    if(msValue !== dayMS) {
      remainingTimings = $scope.availableTimes.slice(1,index -1);
    }
    $scope.closingTimes = $scope.closingTimes.concat(remainingTimings);
    $scope.selectedToTime = $scope.closingTimes[0];
  }
});
app.js

var app = angular.module('angularjs-starter', []);

app.controller('MainCtrl', function($scope) {
  $scope.availableTimes = [];
  $scope.selectedFromTime = {
    'msValue': 0,
    'display': '12:00 Morning'
  };

 $scope.availableTimes.push($scope.selectedFromTime);

  for (var msValue = 900000; msValue <= 85500000; msValue += 900000) { // 90.000ms = 15 min, 85.500.000ms = 11:45PM
    $scope.availableTimes.push({
      'msValue': msValue,
      'display': moment(msValue).utc().format("h:mm A")
    })
  }
  var dayMS = 86400000 - 1;
  $scope.availableTimes.push({
    'msValue': dayMS,
    'display': '12:00 Midnight'
  });

  $scope.skipValues = function(value, index, array) {
    return value.msValue > $scope.selectedFromTime.msValue ;
};

  console.log($scope.availableTimes);
});
    <head lang="en">
      <meta charset="utf-8" />
      <title>Custom Plunker</title>
      <script data-require="moment.js@*" data-semver="2.14.1" src="https://npmcdn.com/moment@2.14.1"></script>
      <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.js"></script>
      <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.0/css/bootstrap-combined.min.css" rel="stylesheet" />
      <link rel="stylesheet" href="style.css" />
      <script>
        document.write('<base href="' + document.location + '" />');
      </script>
      <script src="pagination.js"></script>
      <script src="app.js"></script>
    </head>

    <body ng-controller="MainCtrl">
      <div class="row">
        <div class="col-md-6">
          <div class="form-group">
            <label for="exampleFormControlSelect1">Opening Hours</label>
            <select class="form-control" data-ng-options="time.display for time in availableTimes" data-ng-model="selectedFromTime" ng-change="automaticallySelectClosingTime(selectedFromTime.msValue)">
            </select>
          </div>
        </div>
        <div class="col-md-6">
          <div class="form-group">
            <label for="exampleFormControlSelect1">Closing Hours</label>
             <select class="form-control" data-ng-options="time.display for time in closingTimes" data-ng-model="selectedToTime">
            </select>
          </div>
        </div>
      </div>
    </body>

    </html>

index.html

var app = angular.module('angularjs-starter', []);

app.controller('MainCtrl', function($scope) {
  $scope.availableTimes = [];
  $scope.closingTimes = [];
  $scope.availableTimes.push({
    'msValue': 0,
    'display': '12:00 Morning'
  });
  for (var msValue = 900000; msValue <= 85500000; msValue += 900000) { // 90.000ms = 15 min, 85.500.000ms = 11:45PM
    $scope.availableTimes.push({
      'msValue': msValue,
      'display': moment(msValue).utc().format("h:mm A")
    })
  }
  var dayMS = 86400000 - 1;
  $scope.availableTimes.push({
    'msValue': dayMS,
    'display': '12:00 Midnight'
  });
  $scope.closingTimes = $scope.availableTimes;
  console.log($scope.availableTimes);

  $scope.automaticallySelectClosingTime = function(msValue) {
    $scope.closingTimes = $scope.availableTimes;
    var remainingTimings = [];
    var index = $scope.closingTimes.map(function(obj){return obj.msValue;}).indexOf(msValue);
    index = (index === $scope.availableTimes.length-1) ? 1 : index+1;
    $scope.closingTimes = $scope.closingTimes.slice(index,$scope.availableTimes.length);
    if(msValue !== dayMS) {
      remainingTimings = $scope.availableTimes.slice(1,index -1);
    }
    $scope.closingTimes = $scope.closingTimes.concat(remainingTimings);
    $scope.selectedToTime = $scope.closingTimes[0];
  }
});
var-app=angular.module('angularjs-starter',[]);
应用程序控制器('MainCtrl',函数($scope){
$scope.availableTimes=[];
$scope.selectedFromTime={
“msValue”:0,
“显示”:“上午12:00”
};
$scope.availableTimes.push($scope.selectedFromTime);
对于(var msValue=900000;msValue$scope.selectedFromTime.msValue;
};
log($scope.availableTimes);
});
index.html

<!DOCTYPE html>
<html ng-app="angularjs-starter">

<head lang="en">
  <meta charset="utf-8" />
  <title>Custom Plunker</title>
  <script data-require="moment.js@*" data-semver="2.14.1" src="https://npmcdn.com/moment@2.14.1"></script>
  <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.js"></script>
  <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.0/css/bootstrap-combined.min.css" rel="stylesheet" />
  <link rel="stylesheet" href="style.css" />
  <script>
    document.write('<base href="' + document.location + '" />');
  </script>
  <script src="pagination.js"></script>
  <script src="app.js"></script>
</head>

<body ng-controller="MainCtrl">
  <div class="row">
    <div class="col-md-6">
      <div class="form-group">
        <label for="exampleFormControlSelect1">Opening Hours</label>
        <select class="form-control" data-ng-options="time.display for time in availableTimes" data-ng-model="selectedFromTime" ng-change="automaticallySelectClosingTime()">
        </select>
      </div>
    </div>
    <div class="col-md-6">
      <div class="form-group">
        <label for="exampleFormControlSelect1">Closing Hours</label>
         <select class="form-control" data-ng-options="time.display for time in availableTimes | filter:skipValues" data-ng-model="selectedToTime">
        </select>
      </div>
    </div>
  </div>
</body>

</html>
    <head lang="en">
      <meta charset="utf-8" />
      <title>Custom Plunker</title>
      <script data-require="moment.js@*" data-semver="2.14.1" src="https://npmcdn.com/moment@2.14.1"></script>
      <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.js"></script>
      <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.0/css/bootstrap-combined.min.css" rel="stylesheet" />
      <link rel="stylesheet" href="style.css" />
      <script>
        document.write('<base href="' + document.location + '" />');
      </script>
      <script src="pagination.js"></script>
      <script src="app.js"></script>
    </head>

    <body ng-controller="MainCtrl">
      <div class="row">
        <div class="col-md-6">
          <div class="form-group">
            <label for="exampleFormControlSelect1">Opening Hours</label>
            <select class="form-control" data-ng-options="time.display for time in availableTimes" data-ng-model="selectedFromTime" ng-change="automaticallySelectClosingTime(selectedFromTime.msValue)">
            </select>
          </div>
        </div>
        <div class="col-md-6">
          <div class="form-group">
            <label for="exampleFormControlSelect1">Closing Hours</label>
             <select class="form-control" data-ng-options="time.display for time in closingTimes" data-ng-model="selectedToTime">
            </select>
          </div>
        </div>
      </div>
    </body>

    </html>

index.html

var app = angular.module('angularjs-starter', []);

app.controller('MainCtrl', function($scope) {
  $scope.availableTimes = [];
  $scope.closingTimes = [];
  $scope.availableTimes.push({
    'msValue': 0,
    'display': '12:00 Morning'
  });
  for (var msValue = 900000; msValue <= 85500000; msValue += 900000) { // 90.000ms = 15 min, 85.500.000ms = 11:45PM
    $scope.availableTimes.push({
      'msValue': msValue,
      'display': moment(msValue).utc().format("h:mm A")
    })
  }
  var dayMS = 86400000 - 1;
  $scope.availableTimes.push({
    'msValue': dayMS,
    'display': '12:00 Midnight'
  });
  $scope.closingTimes = $scope.availableTimes;
  console.log($scope.availableTimes);

  $scope.automaticallySelectClosingTime = function(msValue) {
    $scope.closingTimes = $scope.availableTimes;
    var remainingTimings = [];
    var index = $scope.closingTimes.map(function(obj){return obj.msValue;}).indexOf(msValue);
    index = (index === $scope.availableTimes.length-1) ? 1 : index+1;
    $scope.closingTimes = $scope.closingTimes.slice(index,$scope.availableTimes.length);
    if(msValue !== dayMS) {
      remainingTimings = $scope.availableTimes.slice(1,index -1);
    }
    $scope.closingTimes = $scope.closingTimes.concat(remainingTimings);
    $scope.selectedToTime = $scope.closingTimes[0];
  }
});

海关抢劫犯
文件。写(“”);
营业时间
闭馆时间

我已更新了您的代码

    <head lang="en">
      <meta charset="utf-8" />
      <title>Custom Plunker</title>
      <script data-require="moment.js@*" data-semver="2.14.1" src="https://npmcdn.com/moment@2.14.1"></script>
      <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.js"></script>
      <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.0/css/bootstrap-combined.min.css" rel="stylesheet" />
      <link rel="stylesheet" href="style.css" />
      <script>
        document.write('<base href="' + document.location + '" />');
      </script>
      <script src="pagination.js"></script>
      <script src="app.js"></script>
    </head>

    <body ng-controller="MainCtrl">
      <div class="row">
        <div class="col-md-6">
          <div class="form-group">
            <label for="exampleFormControlSelect1">Opening Hours</label>
            <select class="form-control" data-ng-options="time.display for time in availableTimes" data-ng-model="selectedFromTime" ng-change="automaticallySelectClosingTime(selectedFromTime.msValue)">
            </select>
          </div>
        </div>
        <div class="col-md-6">
          <div class="form-group">
            <label for="exampleFormControlSelect1">Closing Hours</label>
             <select class="form-control" data-ng-options="time.display for time in closingTimes" data-ng-model="selectedToTime">
            </select>
          </div>
        </div>
      </div>
    </body>

    </html>

index.html

var app = angular.module('angularjs-starter', []);

app.controller('MainCtrl', function($scope) {
  $scope.availableTimes = [];
  $scope.closingTimes = [];
  $scope.availableTimes.push({
    'msValue': 0,
    'display': '12:00 Morning'
  });
  for (var msValue = 900000; msValue <= 85500000; msValue += 900000) { // 90.000ms = 15 min, 85.500.000ms = 11:45PM
    $scope.availableTimes.push({
      'msValue': msValue,
      'display': moment(msValue).utc().format("h:mm A")
    })
  }
  var dayMS = 86400000 - 1;
  $scope.availableTimes.push({
    'msValue': dayMS,
    'display': '12:00 Midnight'
  });
  $scope.closingTimes = $scope.availableTimes;
  console.log($scope.availableTimes);

  $scope.automaticallySelectClosingTime = function(msValue) {
    $scope.closingTimes = $scope.availableTimes;
    var remainingTimings = [];
    var index = $scope.closingTimes.map(function(obj){return obj.msValue;}).indexOf(msValue);
    index = (index === $scope.availableTimes.length-1) ? 1 : index+1;
    $scope.closingTimes = $scope.closingTimes.slice(index,$scope.availableTimes.length);
    if(msValue !== dayMS) {
      remainingTimings = $scope.availableTimes.slice(1,index -1);
    }
    $scope.closingTimes = $scope.closingTimes.concat(remainingTimings);
    $scope.selectedToTime = $scope.closingTimes[0];
  }
});
使用以下文件:

    <head lang="en">
      <meta charset="utf-8" />
      <title>Custom Plunker</title>
      <script data-require="moment.js@*" data-semver="2.14.1" src="https://npmcdn.com/moment@2.14.1"></script>
      <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.js"></script>
      <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.0/css/bootstrap-combined.min.css" rel="stylesheet" />
      <link rel="stylesheet" href="style.css" />
      <script>
        document.write('<base href="' + document.location + '" />');
      </script>
      <script src="pagination.js"></script>
      <script src="app.js"></script>
    </head>

    <body ng-controller="MainCtrl">
      <div class="row">
        <div class="col-md-6">
          <div class="form-group">
            <label for="exampleFormControlSelect1">Opening Hours</label>
            <select class="form-control" data-ng-options="time.display for time in availableTimes" data-ng-model="selectedFromTime" ng-change="automaticallySelectClosingTime(selectedFromTime.msValue)">
            </select>
          </div>
        </div>
        <div class="col-md-6">
          <div class="form-group">
            <label for="exampleFormControlSelect1">Closing Hours</label>
             <select class="form-control" data-ng-options="time.display for time in closingTimes" data-ng-model="selectedToTime">
            </select>
          </div>
        </div>
      </div>
    </body>

    </html>

index.html

var app = angular.module('angularjs-starter', []);

app.controller('MainCtrl', function($scope) {
  $scope.availableTimes = [];
  $scope.closingTimes = [];
  $scope.availableTimes.push({
    'msValue': 0,
    'display': '12:00 Morning'
  });
  for (var msValue = 900000; msValue <= 85500000; msValue += 900000) { // 90.000ms = 15 min, 85.500.000ms = 11:45PM
    $scope.availableTimes.push({
      'msValue': msValue,
      'display': moment(msValue).utc().format("h:mm A")
    })
  }
  var dayMS = 86400000 - 1;
  $scope.availableTimes.push({
    'msValue': dayMS,
    'display': '12:00 Midnight'
  });
  $scope.closingTimes = $scope.availableTimes;
  console.log($scope.availableTimes);

  $scope.automaticallySelectClosingTime = function(msValue) {
    $scope.closingTimes = $scope.availableTimes;
    var remainingTimings = [];
    var index = $scope.closingTimes.map(function(obj){return obj.msValue;}).indexOf(msValue);
    index = (index === $scope.availableTimes.length-1) ? 1 : index+1;
    $scope.closingTimes = $scope.closingTimes.slice(index,$scope.availableTimes.length);
    if(msValue !== dayMS) {
      remainingTimings = $scope.availableTimes.slice(1,index -1);
    }
    $scope.closingTimes = $scope.closingTimes.concat(remainingTimings);
    $scope.selectedToTime = $scope.closingTimes[0];
  }
});
app.js

var app = angular.module('angularjs-starter', []);

app.controller('MainCtrl', function($scope) {
  $scope.availableTimes = [];
  $scope.selectedFromTime = {
    'msValue': 0,
    'display': '12:00 Morning'
  };

 $scope.availableTimes.push($scope.selectedFromTime);

  for (var msValue = 900000; msValue <= 85500000; msValue += 900000) { // 90.000ms = 15 min, 85.500.000ms = 11:45PM
    $scope.availableTimes.push({
      'msValue': msValue,
      'display': moment(msValue).utc().format("h:mm A")
    })
  }
  var dayMS = 86400000 - 1;
  $scope.availableTimes.push({
    'msValue': dayMS,
    'display': '12:00 Midnight'
  });

  $scope.skipValues = function(value, index, array) {
    return value.msValue > $scope.selectedFromTime.msValue ;
};

  console.log($scope.availableTimes);
});
    <head lang="en">
      <meta charset="utf-8" />
      <title>Custom Plunker</title>
      <script data-require="moment.js@*" data-semver="2.14.1" src="https://npmcdn.com/moment@2.14.1"></script>
      <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.js"></script>
      <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.0/css/bootstrap-combined.min.css" rel="stylesheet" />
      <link rel="stylesheet" href="style.css" />
      <script>
        document.write('<base href="' + document.location + '" />');
      </script>
      <script src="pagination.js"></script>
      <script src="app.js"></script>
    </head>

    <body ng-controller="MainCtrl">
      <div class="row">
        <div class="col-md-6">
          <div class="form-group">
            <label for="exampleFormControlSelect1">Opening Hours</label>
            <select class="form-control" data-ng-options="time.display for time in availableTimes" data-ng-model="selectedFromTime" ng-change="automaticallySelectClosingTime(selectedFromTime.msValue)">
            </select>
          </div>
        </div>
        <div class="col-md-6">
          <div class="form-group">
            <label for="exampleFormControlSelect1">Closing Hours</label>
             <select class="form-control" data-ng-options="time.display for time in closingTimes" data-ng-model="selectedToTime">
            </select>
          </div>
        </div>
      </div>
    </body>

    </html>

index.html

var app = angular.module('angularjs-starter', []);

app.controller('MainCtrl', function($scope) {
  $scope.availableTimes = [];
  $scope.closingTimes = [];
  $scope.availableTimes.push({
    'msValue': 0,
    'display': '12:00 Morning'
  });
  for (var msValue = 900000; msValue <= 85500000; msValue += 900000) { // 90.000ms = 15 min, 85.500.000ms = 11:45PM
    $scope.availableTimes.push({
      'msValue': msValue,
      'display': moment(msValue).utc().format("h:mm A")
    })
  }
  var dayMS = 86400000 - 1;
  $scope.availableTimes.push({
    'msValue': dayMS,
    'display': '12:00 Midnight'
  });
  $scope.closingTimes = $scope.availableTimes;
  console.log($scope.availableTimes);

  $scope.automaticallySelectClosingTime = function(msValue) {
    $scope.closingTimes = $scope.availableTimes;
    var remainingTimings = [];
    var index = $scope.closingTimes.map(function(obj){return obj.msValue;}).indexOf(msValue);
    index = (index === $scope.availableTimes.length-1) ? 1 : index+1;
    $scope.closingTimes = $scope.closingTimes.slice(index,$scope.availableTimes.length);
    if(msValue !== dayMS) {
      remainingTimings = $scope.availableTimes.slice(1,index -1);
    }
    $scope.closingTimes = $scope.closingTimes.concat(remainingTimings);
    $scope.selectedToTime = $scope.closingTimes[0];
  }
});
var-app=angular.module('angularjs-starter',[]);
应用程序控制器('MainCtrl',函数($scope){
$scope.availableTimes=[];
$scope.selectedFromTime={
“msValue”:0,
“显示”:“上午12:00”
};
$scope.availableTimes.push($scope.selectedFromTime);
对于(var msValue=900000;msValue$scope.selectedFromTime.msValue;
};
log($scope.availableTimes);
});
index.html

<!DOCTYPE html>
<html ng-app="angularjs-starter">

<head lang="en">
  <meta charset="utf-8" />
  <title>Custom Plunker</title>
  <script data-require="moment.js@*" data-semver="2.14.1" src="https://npmcdn.com/moment@2.14.1"></script>
  <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.js"></script>
  <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.0/css/bootstrap-combined.min.css" rel="stylesheet" />
  <link rel="stylesheet" href="style.css" />
  <script>
    document.write('<base href="' + document.location + '" />');
  </script>
  <script src="pagination.js"></script>
  <script src="app.js"></script>
</head>

<body ng-controller="MainCtrl">
  <div class="row">
    <div class="col-md-6">
      <div class="form-group">
        <label for="exampleFormControlSelect1">Opening Hours</label>
        <select class="form-control" data-ng-options="time.display for time in availableTimes" data-ng-model="selectedFromTime" ng-change="automaticallySelectClosingTime()">
        </select>
      </div>
    </div>
    <div class="col-md-6">
      <div class="form-group">
        <label for="exampleFormControlSelect1">Closing Hours</label>
         <select class="form-control" data-ng-options="time.display for time in availableTimes | filter:skipValues" data-ng-model="selectedToTime">
        </select>
      </div>
    </div>
  </div>
</body>

</html>
    <head lang="en">
      <meta charset="utf-8" />
      <title>Custom Plunker</title>
      <script data-require="moment.js@*" data-semver="2.14.1" src="https://npmcdn.com/moment@2.14.1"></script>
      <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.js"></script>
      <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.0/css/bootstrap-combined.min.css" rel="stylesheet" />
      <link rel="stylesheet" href="style.css" />
      <script>
        document.write('<base href="' + document.location + '" />');
      </script>
      <script src="pagination.js"></script>
      <script src="app.js"></script>
    </head>

    <body ng-controller="MainCtrl">
      <div class="row">
        <div class="col-md-6">
          <div class="form-group">
            <label for="exampleFormControlSelect1">Opening Hours</label>
            <select class="form-control" data-ng-options="time.display for time in availableTimes" data-ng-model="selectedFromTime" ng-change="automaticallySelectClosingTime(selectedFromTime.msValue)">
            </select>
          </div>
        </div>
        <div class="col-md-6">
          <div class="form-group">
            <label for="exampleFormControlSelect1">Closing Hours</label>
             <select class="form-control" data-ng-options="time.display for time in closingTimes" data-ng-model="selectedToTime">
            </select>
          </div>
        </div>
      </div>
    </body>

    </html>

index.html

var app = angular.module('angularjs-starter', []);

app.controller('MainCtrl', function($scope) {
  $scope.availableTimes = [];
  $scope.closingTimes = [];
  $scope.availableTimes.push({
    'msValue': 0,
    'display': '12:00 Morning'
  });
  for (var msValue = 900000; msValue <= 85500000; msValue += 900000) { // 90.000ms = 15 min, 85.500.000ms = 11:45PM
    $scope.availableTimes.push({
      'msValue': msValue,
      'display': moment(msValue).utc().format("h:mm A")
    })
  }
  var dayMS = 86400000 - 1;
  $scope.availableTimes.push({
    'msValue': dayMS,
    'display': '12:00 Midnight'
  });
  $scope.closingTimes = $scope.availableTimes;
  console.log($scope.availableTimes);

  $scope.automaticallySelectClosingTime = function(msValue) {
    $scope.closingTimes = $scope.availableTimes;
    var remainingTimings = [];
    var index = $scope.closingTimes.map(function(obj){return obj.msValue;}).indexOf(msValue);
    index = (index === $scope.availableTimes.length-1) ? 1 : index+1;
    $scope.closingTimes = $scope.closingTimes.slice(index,$scope.availableTimes.length);
    if(msValue !== dayMS) {
      remainingTimings = $scope.availableTimes.slice(1,index -1);
    }
    $scope.closingTimes = $scope.closingTimes.concat(remainingTimings);
    $scope.selectedToTime = $scope.closingTimes[0];
  }
});

海关抢劫犯
文件。写(“”);
营业时间
闭馆时间
请检查链接:

    <head lang="en">
      <meta charset="utf-8" />
      <title>Custom Plunker</title>
      <script data-require="moment.js@*" data-semver="2.14.1" src="https://npmcdn.com/moment@2.14.1"></script>
      <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.js"></script>
      <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.0/css/bootstrap-combined.min.css" rel="stylesheet" />
      <link rel="stylesheet" href="style.css" />
      <script>
        document.write('<base href="' + document.location + '" />');
      </script>
      <script src="pagination.js"></script>
      <script src="app.js"></script>
    </head>

    <body ng-controller="MainCtrl">
      <div class="row">
        <div class="col-md-6">
          <div class="form-group">
            <label for="exampleFormControlSelect1">Opening Hours</label>
            <select class="form-control" data-ng-options="time.display for time in availableTimes" data-ng-model="selectedFromTime" ng-change="automaticallySelectClosingTime(selectedFromTime.msValue)">
            </select>
          </div>
        </div>
        <div class="col-md-6">
          <div class="form-group">
            <label for="exampleFormControlSelect1">Closing Hours</label>
             <select class="form-control" data-ng-options="time.display for time in closingTimes" data-ng-model="selectedToTime">
            </select>
          </div>
        </div>
      </div>
    </body>

    </html>

index.html

var app = angular.module('angularjs-starter', []);

app.controller('MainCtrl', function($scope) {
  $scope.availableTimes = [];
  $scope.closingTimes = [];
  $scope.availableTimes.push({
    'msValue': 0,
    'display': '12:00 Morning'
  });
  for (var msValue = 900000; msValue <= 85500000; msValue += 900000) { // 90.000ms = 15 min, 85.500.000ms = 11:45PM
    $scope.availableTimes.push({
      'msValue': msValue,
      'display': moment(msValue).utc().format("h:mm A")
    })
  }
  var dayMS = 86400000 - 1;
  $scope.availableTimes.push({
    'msValue': dayMS,
    'display': '12:00 Midnight'
  });
  $scope.closingTimes = $scope.availableTimes;
  console.log($scope.availableTimes);

  $scope.automaticallySelectClosingTime = function(msValue) {
    $scope.closingTimes = $scope.availableTimes;
    var remainingTimings = [];
    var index = $scope.closingTimes.map(function(obj){return obj.msValue;}).indexOf(msValue);
    index = (index === $scope.availableTimes.length-1) ? 1 : index+1;
    $scope.closingTimes = $scope.closingTimes.slice(index,$scope.availableTimes.length);
    if(msValue !== dayMS) {
      remainingTimings = $scope.availableTimes.slice(1,index -1);
    }
    $scope.closingTimes = $scope.closingTimes.concat(remainingTimings);
    $scope.selectedToTime = $scope.closingTimes[0];
  }
});
我已更新了您的代码

    <head lang="en">
      <meta charset="utf-8" />
      <title>Custom Plunker</title>
      <script data-require="moment.js@*" data-semver="2.14.1" src="https://npmcdn.com/moment@2.14.1"></script>
      <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.js"></script>
      <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.0/css/bootstrap-combined.min.css" rel="stylesheet" />
      <link rel="stylesheet" href="style.css" />
      <script>
        document.write('<base href="' + document.location + '" />');
      </script>
      <script src="pagination.js"></script>
      <script src="app.js"></script>
    </head>

    <body ng-controller="MainCtrl">
      <div class="row">
        <div class="col-md-6">
          <div class="form-group">
            <label for="exampleFormControlSelect1">Opening Hours</label>
            <select class="form-control" data-ng-options="time.display for time in availableTimes" data-ng-model="selectedFromTime" ng-change="automaticallySelectClosingTime(selectedFromTime.msValue)">
            </select>
          </div>
        </div>
        <div class="col-md-6">
          <div class="form-group">
            <label for="exampleFormControlSelect1">Closing Hours</label>
             <select class="form-control" data-ng-options="time.display for time in closingTimes" data-ng-model="selectedToTime">
            </select>
          </div>
        </div>
      </div>
    </body>

    </html>

index.html

var app = angular.module('angularjs-starter', []);

app.controller('MainCtrl', function($scope) {
  $scope.availableTimes = [];
  $scope.closingTimes = [];
  $scope.availableTimes.push({
    'msValue': 0,
    'display': '12:00 Morning'
  });
  for (var msValue = 900000; msValue <= 85500000; msValue += 900000) { // 90.000ms = 15 min, 85.500.000ms = 11:45PM
    $scope.availableTimes.push({
      'msValue': msValue,
      'display': moment(msValue).utc().format("h:mm A")
    })
  }
  var dayMS = 86400000 - 1;
  $scope.availableTimes.push({
    'msValue': dayMS,
    'display': '12:00 Midnight'
  });
  $scope.closingTimes = $scope.availableTimes;
  console.log($scope.availableTimes);

  $scope.automaticallySelectClosingTime = function(msValue) {
    $scope.closingTimes = $scope.availableTimes;
    var remainingTimings = [];
    var index = $scope.closingTimes.map(function(obj){return obj.msValue;}).indexOf(msValue);
    index = (index === $scope.availableTimes.length-1) ? 1 : index+1;
    $scope.closingTimes = $scope.closingTimes.slice(index,$scope.availableTimes.length);
    if(msValue !== dayMS) {
      remainingTimings = $scope.availableTimes.slice(1,index -1);
    }
    $scope.closingTimes = $scope.closingTimes.concat(remainingTimings);
    $scope.selectedToTime = $scope.closingTimes[0];
  }
});

海关抢劫犯
文件。写(“”);
营业时间
闭馆时间
index.html
var app=angular.module('angularjs-starter',[]);
应用程序控制器('MainCtrl',函数($scope){
$scope.availableTimes=[];
$scope.closingTimes=[];
$scope.availableTimes.push({
“msValue”:0,
“显示”:“上午12:00”
});
对于(var msValue=900000;msValue请查看链接:

    <head lang="en">
      <meta charset="utf-8" />
      <title>Custom Plunker</title>
      <script data-require="moment.js@*" data-semver="2.14.1" src="https://npmcdn.com/moment@2.14.1"></script>
      <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.js"></script>
      <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.0/css/bootstrap-combined.min.css" rel="stylesheet" />
      <link rel="stylesheet" href="style.css" />
      <script>
        document.write('<base href="' + document.location + '" />');
      </script>
      <script src="pagination.js"></script>
      <script src="app.js"></script>
    </head>

    <body ng-controller="MainCtrl">
      <div class="row">
        <div class="col-md-6">
          <div class="form-group">
            <label for="exampleFormControlSelect1">Opening Hours</label>
            <select class="form-control" data-ng-options="time.display for time in availableTimes" data-ng-model="selectedFromTime" ng-change="automaticallySelectClosingTime(selectedFromTime.msValue)">
            </select>
          </div>
        </div>
        <div class="col-md-6">
          <div class="form-group">
            <label for="exampleFormControlSelect1">Closing Hours</label>
             <select class="form-control" data-ng-options="time.display for time in closingTimes" data-ng-model="selectedToTime">
            </select>
          </div>
        </div>
      </div>
    </body>

    </html>

index.html

var app = angular.module('angularjs-starter', []);

app.controller('MainCtrl', function($scope) {
  $scope.availableTimes = [];
  $scope.closingTimes = [];
  $scope.availableTimes.push({
    'msValue': 0,
    'display': '12:00 Morning'
  });
  for (var msValue = 900000; msValue <= 85500000; msValue += 900000) { // 90.000ms = 15 min, 85.500.000ms = 11:45PM
    $scope.availableTimes.push({
      'msValue': msValue,
      'display': moment(msValue).utc().format("h:mm A")
    })
  }
  var dayMS = 86400000 - 1;
  $scope.availableTimes.push({
    'msValue': dayMS,
    'display': '12:00 Midnight'
  });
  $scope.closingTimes = $scope.availableTimes;
  console.log($scope.availableTimes);

  $scope.automaticallySelectClosingTime = function(msValue) {
    $scope.closingTimes = $scope.availableTimes;
    var remainingTimings = [];
    var index = $scope.closingTimes.map(function(obj){return obj.msValue;}).indexOf(msValue);
    index = (index === $scope.availableTimes.length-1) ? 1 : index+1;
    $scope.closingTimes = $scope.closingTimes.slice(index,$scope.availableTimes.length);
    if(msValue !== dayMS) {
      remainingTimings = $scope.availableTimes.slice(1,index -1);
    }
    $scope.closingTimes = $scope.closingTimes.concat(remainingTimings);
    $scope.selectedToTime = $scope.closingTimes[0];
  }
});
我已更新了您的代码

    <head lang="en">
      <meta charset="utf-8" />
      <title>Custom Plunker</title>
      <script data-require="moment.js@*" data-semver="2.14.1" src="https://npmcdn.com/moment@2.14.1"></script>
      <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.js"></script>
      <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.0/css/bootstrap-combined.min.css" rel="stylesheet" />
      <link rel="stylesheet" href="style.css" />
      <script>
        document.write('<base href="' + document.location + '" />');
      </script>
      <script src="pagination.js"></script>
      <script src="app.js"></script>
    </head>

    <body ng-controller="MainCtrl">
      <div class="row">
        <div class="col-md-6">
          <div class="form-group">
            <label for="exampleFormControlSelect1">Opening Hours</label>
            <select class="form-control" data-ng-options="time.display for time in availableTimes" data-ng-model="selectedFromTime" ng-change="automaticallySelectClosingTime(selectedFromTime.msValue)">
            </select>
          </div>
        </div>
        <div class="col-md-6">
          <div class="form-group">
            <label for="exampleFormControlSelect1">Closing Hours</label>
             <select class="form-control" data-ng-options="time.display for time in closingTimes" data-ng-model="selectedToTime">
            </select>
          </div>
        </div>
      </div>
    </body>

    </html>

index.html

var app = angular.module('angularjs-starter', []);

app.controller('MainCtrl', function($scope) {
  $scope.availableTimes = [];
  $scope.closingTimes = [];
  $scope.availableTimes.push({
    'msValue': 0,
    'display': '12:00 Morning'
  });
  for (var msValue = 900000; msValue <= 85500000; msValue += 900000) { // 90.000ms = 15 min, 85.500.000ms = 11:45PM
    $scope.availableTimes.push({
      'msValue': msValue,
      'display': moment(msValue).utc().format("h:mm A")
    })
  }
  var dayMS = 86400000 - 1;
  $scope.availableTimes.push({
    'msValue': dayMS,
    'display': '12:00 Midnight'
  });
  $scope.closingTimes = $scope.availableTimes;
  console.log($scope.availableTimes);

  $scope.automaticallySelectClosingTime = function(msValue) {
    $scope.closingTimes = $scope.availableTimes;
    var remainingTimings = [];
    var index = $scope.closingTimes.map(function(obj){return obj.msValue;}).indexOf(msValue);
    index = (index === $scope.availableTimes.length-1) ? 1 : index+1;
    $scope.closingTimes = $scope.closingTimes.slice(index,$scope.availableTimes.length);
    if(msValue !== dayMS) {
      remainingTimings = $scope.availableTimes.slice(1,index -1);
    }
    $scope.closingTimes = $scope.closingTimes.concat(remainingTimings);
    $scope.selectedToTime = $scope.closingTimes[0];
  }
});

海关抢劫犯
文件。写(“”);
营业时间
闭馆时间
index.html
var app=angular.module('angularjs-starter',[]);
应用程序控制器('MainCtrl',函数($scope){
$scope.availableTimes=[];
$scope.closingTimes=[];
$scope.availableTimes.push({
“msValue”:0,
“显示”:“上午12:00”
});

对于(var msValue=900000;msValue可能的重复是我试图实现的相似之处,但如何实现这种情况:开放时间周日11:00上午结束时间2:00可能的重复是我试图实现的相似之处,但如何实现这种情况:开放时间周日11:00上午结束时间2:00上午这是awesome。只有一件事。如果有人想选择上午10:00的开放时间和凌晨2:00的关闭时间,这将是不可能的,因为午夜后下拉列表中没有选项。如何解决这种情况。你能帮我写我的新帖子吗?这太棒了。只有一件事。如果有人想选择上午10:00的开放时间和Clo凌晨2:00唱歌是不可能的,因为午夜后下拉列表中没有选项。如何解决这种情况。你能帮我写我的新帖子吗?这太完美了。我想如果可以将它转换成指令会更好。有什么意见吗?只是想知道如果开始时间和结束时间的值为pres,它将如何工作使用ng模型选择?那么关闭时间将不遵循顺序,只需调用与您为ng模型变量赋值相同的函数即可。您的意思是调用$scope.automaticallySelectClosingTime()?是的。发送预选的开放时间值,您将得到关闭时间列表。这很完美。我想如果可以将其转换为指令,它会更好。有什么意见吗?只是想知道如果使用ng模型预选开放时间和关闭时间值,它将如何工作?那么关闭时间将不会遵循顺序,只需调用相同的函数即可其中u为ng模型变量赋值。是否要调用$scope.automaticallySelectClosingTime()?是。发送预选的打开时间值,您将获得关闭时间列表