Rendy Rendy - 5 months ago 24
AngularJS Question

Map depends on dynamic variable

I have following hardcoded map:

$scope.lists = {
test1: [
{ name: 'My Name' }
test2: [
{ name: 'My Second Name' }

$scope.selectedList = "test1";

Then inside my pug/html file:

div(ng-repeat="list in lists.selectedList")

What I need is I want to have array to be selected depend on var of
. Am I able to do that in AngularJS?


You can use square-bracket syntax in angular attributes:

 div(ng-repeat="list in lists[selectedList]")