All I want to do is show the selected item below the master list o' items. I've done this before, but for some reason it's just not behaving and I can't figure out what I'm missing.
the html (trimmed down to just the relevant part):
<ul>
<li data-ng-repeat="user in users" ng-click="$parent.selectUser($index)" ng-model="$index">
{{user.userName}}
</li>
</ul>
<p>Selected: {{selected.userName}}, #<b>{{$index}}</b></p>
the js:
(function (app) {
app.controller('UsersController', [ '$scope', function ($scope) {
$scope.selectUser = function ($index) {
$scope.selected = $index;
console.info('selected1=' + $index);
};
$scope.selected = null;
}]);
});
The console log shows up with the index of the selection, but nothing happens in the last line of the html -- no selected.userName, no $index. I've tried all kinds of variations and nothing happens. What am I missing? Thanks in advance!
(note: I'm not sure I'm using ng-model there correctly, either, but that seems to be incidental to whether or not I can get the selected $index to show up.)