I am working on loading data from (entity framework/sql view) to a drop-down menu in my app front end.
I am able to call the server side method and successfully verify that the results contain the data that I need.
I am making a mistake in how I am accessing the elements of the data array, that I intend to use to populate the drop-down menu. After I complete the execution, the drop-down menu displays "unidefined" 37 times, which is the number of records the GET returns.
Here is what I see in Chrome developer tools:
As you can see, I assign the data.data to my $scope.MeetingListarray.
in the html view I attempt to use the contents of $scope.MeetingListas follows:
<div>
<select ng-model="selectedMeeting">
<option value="">--Select Meetings--</option>
<option ng-repeat="meeting in MeetingList" value="{{meeting.MeetingID}}">{{meeting.MeetingName}}</option>
</select>
</div>
AngularJS
app.controller('MyController', ['$scope', '$http', '$window', function ($scope, $http, $window) {
$scope.selectedMeeting = null;
$scope.MeetingList = [];
$http({
method: 'GET',
url: '/VirtualMeetings/CrossReference/Home/GetMeetingList',
data: {}
}).then(function (data) {
$scope.MeetingList = data;
});
What am I doing incorrectly when populating the array and using it in the html view? Could someone please show me mi error, and the right way of coding this?
Greatly appreciated it.
Thank you.
Updated Screen-Shot
This worked for me, in order to populate the drop down menu/list
html view:
<select ng-model="model.selectedMeeting">
<option ng-repeat="meeting in MeetingList" value="{{meeting.MeetingID}}">{{meeting.MeetingTitle}}</option>
<option value="">--Select Meeting--</option>
</select>
angularjs
$http({
method: 'GET',
url: '/VirtualMeetings/CrossReference/Home/GetMeetingList',
data: {}
}).then(function (res) {
$scope.MeetingList = res.data.data;
});
I needed to add one more data in the assignment of array.