Archish Archish - 5 months ago 8
AngularJS Question

How to create expression array in angularjs

This is my js code.

$ function(docid,addid){
method: 'POST',
url: "http://localhost:81/DoctorStayServiceAngular/model/getDoctorBookingDetail.php",
}).then(function mySucces(response) {
$scope.count= i;


and This is HTML.

<div id="DocAppoinment" class="col-sm-3" ng-init="booking(x.profileid,x.addressid)">
<span ng-bind="count"></span>

And This is my output

My outout

js function will give me 10 list,and i want to display 1 to 10 on right hand side, as you can see in output it's getting overwritten for obvious reason.

so what should do to print 1 to 10 on right hand side? is there expression array or something in angular? any suggestion?

PS: I am new to this framework.


I wouldn't call it a solid solution but one way would be to take advantage of track-by in your ng-repeat .

example: ng-repeat="x in exxes track by $index" and use {{$index+1}} to display the number in your html.

So it would look like

<div ng-repeat="x in exs track by $index">
   <div id="DocAppoinment" class="col-sm-3" ng-init="booking(x.profileid,x.addressid)">
        <span  ng-bind="count">{{$index + 1}}</span>