Angular: ngSwitch with ngRepeat
Obviously not working
by alfrescian
HTML
<div ng-controller="MyCtrl">
<div class="click">
<div ng-repeat="test in tests" data-ng-click="sw='{{test.name}}'">
{{test.name}}
</div>
</div>
<div class="switch" data-ng-switch="sw">
<div ng-repeat="test in tests" ng-switch-when="{{test.name}}">
{{test.text}}
</div>
</div>
</div>
CSS
.click {
padding: 10px;
display: inline-block;
}
.switch {
color: blue;
display: inline-block;
vertical-align: top;
padding: 10px;
}
JavaScript
var myApp = angular.module('myApp',[]);
function MyCtrl($scope) {
$scope.tests = [
{"name": "Test1", "text": "Some text 1"},
{"name": "Test2", "text": "Some text 2"},
{"name": "Test3", "text": "Some text 3"}];
}