Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pass array into ng-click

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>

When the button is not within ng-repeat, how can I pass my item's id into ng-click function?

like image 713
Jennifer Avatar asked May 24 '26 05:05

Jennifer


1 Answers

Well items is already on $scope as you're using it in your ng-repeat. So you should simply be able to ng-click="send(items)"

like image 60
juco Avatar answered May 26 '26 17:05

juco



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!