Say I have a variable x with a value of 7, I need to echo out this html
<a href="#" data-page="{{y}}">{{y}}</a>
Where y is 1,2,3... until y == x. How do I do this in Angular?
Say I have a variable x with a value of 7, I need to echo out this html
<a href="#" data-page="{{y}}">{{y}}</a>
Where y is 1,2,3... until y == x. How do I do this in Angular?
Using this answer you can create a filter which does this for you:
HTML
<div ng-app='myApp' ng-controller="Main">
<a href="#" ng-repeat="y in range(1,7)" data-page="{{y}}">{{y}}</a>
</div>
Controller
var myApp = angular.module('myApp', []);
function Main($scope){
$scope.range = function(min, max){
var input = [];
for (var i=min; i<=max; i++) input.push(i);
return input;
};
};