-1

I have this code that increment the number "count":

<button ng-click="count = count + 1" ng-init="count=0">
  Increment
</button>
<span>
  count: {{count}}
</span>

And I want the number "count" control det index of this list:

<p>@month.get({{count}})</p>

But this way isn't work..

EspenG
  • 537
  • 3
  • 10
  • 20

1 Answers1

2

Put the get inside your controller, and then you can just display the result.

In the html:

<p>Month: {{getMonth(count)}}</p>

and in the controller:

$scope.getMonth = function (m) {
    return month[m];
}

Here's a fiddle using a simple list of months - you can replace the getMonth function with whatever is needed to get your particular data.

James Waddington
  • 2,894
  • 2
  • 15
  • 24
  • Do you now how I set var month to my scala list? I send it to the html like this @(month: List[String]) – EspenG Jan 15 '15 at 11:34
  • I'm not familiar with scala, but a typical approach would be to have a simple rest service on your server side which prints the list, and then get that in your angular controller using $http or $resource (https://docs.angularjs.org/api/ngResource/service/$resource). – James Waddington Jan 15 '15 at 14:44