I would like to use tabs to hide and show items in an ng-repeat. Is it possible to change the value of a scope like so?
<a ng-click="packageType = '1'">Package 1</a><a ng-click="packageType ='2'">Package 2</a><a ng-click="packageType = '3'">Package 3</a>
<div ng-repeat="item in packages" ng-show="packageType >=item.packageID">
{{item.name}}</div>
and the scope:
$scope.packages = [...{ "name": "some name",
"packageID": 1}...]
Where packageID can be 1, 2 or 3?
You code has a few problems:
You first ng-click is does not have a closing quote.
You set packageType to a string when it is a number later:
You don't need {{}} in the ng-show
I think you meant for packages to be an array instead of an object:
Example of how to do it is below. I set it to show on the second and third links :
Here's the code that does exactly what your asking
Plunker
So I assume packages is an array and what you posted is not your complete code. You will want to change your ng-show to say
this will only show the div if the packageID is the same as the package type. Your ng-click should work fine. You will want to set a default value for packageType somewhere in your controller however so something shows initially
I would write a function that encapsulates what you want to happen on click. That would make it easier to understand.