Ashish Goyal Ashish Goyal - 5 months ago 11
HTML Question

i try to make gap interval or say add constant value in array

i just want to show time gap i.e 9:00 9:20 9:40 (20 minutes gap)

<div ng-app='myApp' ng-controller="Main">

<div ng-repeat="n in [] | range:5">
9:00
</div>




var myApp = angular.module('myApp', []);
myApp.controller('Main', function() {
var start_time = 1;
var end_time = 10;
var step = 2;

for (var i=start_time; i<end_time; i+=step) {
input.push(i);
return $scope.input;
};
});

Answer

You can do something.

Here is a link to a jsbin: http://jsbin.com/fugafeyafo/edit?html,js,output

<div ng-repeat="d in timeArray">{{d | date: "HH:mm"}}</div>

In javascript.

var myApp = angular.module('myApp', []);
myApp.controller('Main',['$scope', function($scope) {
    $scope.timeArray = [];
    var startDate = new Date().getTime();
    [1,2,3,4,5].forEach(function(n, i){
        $scope.timeArray.push(new Date(startDate + n * 20 * 60 * 1000));
    });
}]);

Output:

22:42

23:02

23:22

23:42

00:02

Comments