This might sound like a silly question but I've been stuck on this one for a few hours. There must be something amazingly simple I'm overlooking.
I've got an ng-repeat directive which is outputting a list of items:
<div ng-controller="MyCtrl">
<div ng-repeat="foo in bars">
....
</div>
</div>
And then inside, at the end of the list I've got a form to add to the list:
<div class="add">
<input ng-model="valueToAdd" class="weight" />
<a ng-click="addStuff()" class="button-small"> + Add</a>
</div>
The addStuff() method is on my controller:
function MyCtrl($scope) {
$scope.addStuff= function () {
alert($scope.valueToAdd);
}
}
But $scope.valueToAdd always gives me undefined.
What am I missing?
EDIT: Here's a punker where this problem is reproduced: http://plnkr.co/edit/YoGdx8?p=preview