Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/423.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 ng重复构建时间表_Javascript_Angularjs_Arrays - Fatal编程技术网

Javascript ng重复构建时间表

Javascript ng重复构建时间表,javascript,angularjs,arrays,Javascript,Angularjs,Arrays,我试图构建一个简单的24小时时间表,如下所示 -00:00 - -00:30 - -01:00 - -01:30 - ... 我一直在摆弄着像 <table> <tr ng-repeat="t in _.range(0, 24) track by $index"> <td>{{$index % 2 === 1 ? '-' : ( t | leadingzero : 2)}}</td> </tr> <table&

我试图构建一个简单的24小时时间表,如下所示

-00:00
-
-00:30
-
-01:00
-
-01:30
-
...
我一直在摆弄着像

<table>
  <tr ng-repeat="t in _.range(0, 24) track by $index">
     <td>{{$index % 2 === 1 ? '-' : ( t | leadingzero : 2)}}</td>
  </tr>
<table>  

{{$index%2==1?'-':(t | leadingzero:2)}
显然这不起作用。有人能提供更好的解决方案吗?谢谢

试试这个解决方案:

(函数(角度){
"严格使用",;
var myApp=angular.module('app',[]);
myApp.controller('TestController',['$scope',函数($scope){
$scope.ranges=函数(从,到){
var-res=[];
for(var i=from;i9?“:“0”)+i+“:00”);
返回res;
}
}]);
})(窗口角度)

-{{range}}
-
尝试以下解决方案:

(函数(角度){
"严格使用",;
var myApp=angular.module('app',[]);
myApp.controller('TestController',['$scope',函数($scope){
$scope.ranges=函数(从,到){
var-res=[];
for(var i=from;i9?“:“0”)+i+“:00”);
返回res;
}
}]);
})(窗口角度)

-{{range}}
-

您可以阅读本文:了解如何通过定义自己的过滤器在范围上循环。这真的很方便。你可以阅读这篇文章:通过定义你自己的过滤器来了解如何在范围上循环。非常方便。谢谢!太棒了![code]res.push((temp>9?:“0”)+temp+(i%2==1?:30)::00”);[/COD]我需要如何改变这一点,用“-”和“删除空白”的“完美”替换“**:30”。非常感谢你!谢谢太棒了![code]res.push((temp>9?:“0”)+temp+(i%2==1?:30)::00”);[/COD]我需要如何改变这一点,用“-”和“删除空白”的“完美”替换“**:30”。非常感谢你!