I need to populate my option fields with data retrieved from a database. I encountered an error in the console:
Error: [$compile:ctreq] Controller 'select', required by directive 'ngOptions', can't be found!
I am confident that the JSON is sending my data correctly, as I received the following output when I accessed this URL: myaddress.com/forms/usersDB.php?action=get_Logins_info
Output:
[{"id":"1","name":"John"},{"id":"2","name":"Julia"}]
Angular Function:
$scope.ChooseLogins = [];
$scope.getLogins = function () {
$http.get('forms/usersDB.php?action=get_Logins_info').then(function (data, status, headers, config) {
$scope.chooseLogins = data;
console.log('Retrieved data from server');
console.log(data);
}).then(function (data, status, headers, config) {
console.log("Error in retrieving data from server");
console.log(data, status);
});
};
$scope.getLogins();
HTML:
<md-select ng-model="getLogins" ng-options="logins.id for logins in chooseLogins">
<md-option value="{{logins.id}}">{{logins.name}}</md-option>
</md-select>