I have a simple widget I'm building that has multiple panes. I'm trying to switch between them by way of font-awesome icons along the top. My $scope
has a model selected
that I'd like to update when people click one of the icons.
I have been able to accomplish this by invoking a method off of the $scope
, like so:
<i ng-repeat="cat in widget.data"
ng-click="updateSelected(cat.type)">
</i>
and in my controller:
$scope.updateSelected = function (type) { $scope.selected = type; };
However, I'd like to do it more directly by updating the selected
model directly in the ng-click
attribute, like so:
<i ng-repeat="cat in widget.data"
ng-click="selected=cat.type">
</i>
I've not been able to get this to work so now I'm wondering -- are you supposed to be able to directly update a model in this fashion? Or do I always need to write a handler function?