Page 1 of 1

Angular Select - Populate List from Array of Objects

Posted: Thu Aug 13, 2015 3:23 pm
by Dave Scott

Hi,

I've been trying for hours to get this to work to no avail. The intention is that I can replicate this http://plnkr.co/edit/Lj0p3wig9JfOM0Uk... using appery with one text input and a select list which is populated from an array of objects

I've setup the array inside the init() function like this:

$scope.options = [{
name: 'a',
value: 'some-value'
}, {
name: 'b',
value: 'some-other-value'
}
];

$scope.selectedOption = $scope.options[0];

Then, on the select item I've set ng-model to selectedObject and also ng-options attribute to option.name for option in options

However, I just can't get the array data into the select list.. What am I doing wrong??

Many thanks,
Dave


Angular Select - Populate List from Array of Objects

Posted: Thu Aug 13, 2015 7:32 pm
by Serhii Kulibaba

Hello Dave,

Have you added options variable on the scope tab?


Angular Select - Populate List from Array of Objects

Posted: Fri Aug 14, 2015 3:46 am
by Dave Scott

Hi Sergiy,

I thought I had read that you could just declare the variables in the Init() function without creating as variables on the variables list in the scope?

Anyway, I tried adding the variable options to the scope per below images and it did not help as I still could not get the data into the Select list..

Seems like it should work, but I cannot see where it is going wrong. Can you provide any further guidance in populating the Select value from a JSON array??

Image Image