I have an array of numbers, e.g:
var data=['1','4','2','1','6','9','1','5',]
and I want to convert it into two-dimensional array, like this one below:
result = [['1','4','2','1'],['6','9','1','5']]
my goal is to make dynamic grid style menu system in ionic from the example below
<div class="text-center" ng-init="models = [['12','1','2','3','3'],['4','4','5','6','7']]">
<div ng-repeat="m in models">
<span class="control-label1" ng-repeat="movie in m track by $index">
{{movie}}</span>
</div>
</div>
in order to do this i needed to add all my value in 2 dimensional array. i am adding value in the given function below
//this function make populate my array with unique value
$scope.addhourinArray = function (value) {
if (value) {
if ($scope.hourArray.indexOf(value) == -1) {
$scope.hourArray.push(value);
}
}
};
for (var i = 0; i < data.length; i++) {
$scope.addhourinArray(hour);
}