[IONIC] create ten buttons with angular js

Hi,

how i create ten buttons on html div with angular js?

The ideia is create one list of buttons like this:

Button 1
Button 2
(…)
Button 10

Best regards

create an array of buttons in your controller, put the buttons array on your scope and then use ng-repeat to display the buttons. You can use ionic css classes on your button div to style the buttons

this is correct?

HTML

<script type="text/ng-template" id="pertodemim.html">
            <ion-view title="Perto de mim" hide-back-button="true">
                <ion-nav-buttons side="left">
                    <a class="button icon icon-right ion-chevron-left button-white no-color no-margin" href="index.html"></a>
                </ion-nav-buttons>
                <ion-content ng-controller="ListRestaurantController" padding="true">
                    <div class="list responsive-sm">    
                        <a class="item item-thumbnail-left" ng-repeat="item in items" ui-sref="restaurante">
                            <h2>{{item}}</h2>   
                        </a>
                    </div>
                </ion-content>
            </ion-view>
        </script>

JS

var exampleApp = angular.module('starter', ['ionic', 'ngCordova'])

exampleApp.controller('ListRestaurantController', function() {
  this.items = [];
  for (var i = 0; i < 1000; i++) this.items.push(i);
});

looks good! did you test it?

Yes but don’t works. I saw many examples or tutorials with code like this and works nothing

Put together a codepen and I’ll check it out