I am trying to a list elements based on a selection with ng-repeat and ng-show, i cant understand why ng-show is not working as expected.
function Ctrl($scope) {
$scope.categories = [
{"name": "alpha"},
{"name": "beta"},
{"name": "gama"}
];
$scope.subcategories = [
{"parent": "alpha",
"text" : "alpha text"},
{"parent": "beta",
"text" : "beta text"},
{"parent": "gama",
"text" : "gama text"}
];
}
-
<div ng-controller="Ctrl">
<div>
Categorie:
<select id="country" ng-model="categorie">
<option value=''>Select</option>
<option ng-repeat="cat in categories" value="{{cat.name}}">{{cat.name}}</option>
</select>
<p>Selected categorie: {{categorie}} </p>
</div>
<div>
<p ng-repeat="x in subcategories" ng-show="x.parent == 'categorie'">
{{x.text}}
</p>
</div>