Is there a way to achieve the following with AngularJS?:
<select>
<option ng-repeat="item in items" value="item">{{item.name}}</option>
</select>
<a ng-click="foo(item)">Action</a>
The function foo
is defined in an Angular controller like this:
$scope.foo = function(item) {
console.log(item);
}
I understand that item
is defined in the scope of the <option>
element. However, I want to pass the currently selected item to the foo
function. How can I accomplish this?