将数组传递到ng-click

时间:2016-04-28 12:52:19

标签: javascript angularjs

http://jsfiddle.net/u0jzkye1/

<div ng-app ng-controller="MyCtrl">
    <ul>
        <li ng-repeat="item in items">{{item.name}}</li>
    </ul>
    <button type="submit" ng-click="send()">
    Send
    </button>
</div>

当按钮不在ng-repeat中时,如何将我的项目ID传递给ng-click功能?

2 个答案:

答案 0 :(得分:1)

items已经在$scope上了,因为您在ng-repeat中使用了ng-click="send(items)"。所以你应该能够jQuery(this).find("> p");

答案 1 :(得分:0)

&#13;
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app ng-controller="MyCtrl">
  <ul>
    <li ng-repeat="item in items">{{item.name}}</li>
  </ul>
  <button type="submit" ng-click="send()">
    Send
  </button>
</div>
&#13;
$(this).find("> p");
&#13;
&#13;
&#13;