如何获得 AngularJS 值

How to get AngularJS value

我有这段代码可以增加数字 "count":

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

我想要这个列表的编号 "count" 控制 det 索引:

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

但是这种方式不行..

把get放在你的controller里面,然后你就可以显示结果了。

在html中:

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

在控制器中:

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

Here's a fiddle 使用简单的月份列表 - 您可以将 getMonth 函数替换为获取特定数据所需的任何内容。