Why an extra object is needed?

Viewed 161

I'm checking the Angular Bootstrap UI, especially the service $modal and noticed an interesting thing.

In their sample here 'http://plnkr.co/edit/E5xYKPQwYtsLJUa6FxWt?p=preview' in the controller that gets attached to the popup window they have enclosed the selected item into another inner property

$scope.selected = {
   item: $scope.items[0]
};

instead of having just

$scope.selected = $scope.items[0];

and indeed their code works as expected while my version does not.

Why is this needed? What's the JavaScript gotcha here?

Thx

2 Answers
Related