As a newcomer to using JavaScript, I've encountered a little issue.
I am working on an Angular JS application where my service /api/service returns JSON with all users in the database.
I have a Factory named "UsersFactory.js" and my Controller is called "UsersController".
UsersController:
var UsersController = function ($scope, $location, UsersFactory, $http) {
$scope.confirmDataForm = {
emailAddress: 'example@email.com',
firstName: 'Ryan',
lastName: '',
organization: '',
organizationType: '',
city: ''
};
UsersFactory:
var ConfirmDataFactory = function ($http, $q) {
return function (emailAddress, firstName, lastName, businessAddress, organization, organizationType, city, state, zip, password) {
var deferredObject = $q.defer();
$http.post('/Account/ConfirmData', {
Email: emailAddress,
FirstName: firstName,
LastName: lastName,
Organization: organization,
OrganizationType: organizationType,
BusinessAddress: businessAddress,
City: city,
State: state,
Zip: zip,
Password: password
})
.success(function (data) {
if (data === "True") {
deferredObject.resolve({ success: true });
} else {
deferredObject.resolve({ success: false });
}
})
.error(function () {
deferredObject.resolve({ success: false });
});
return deferredObject.promise;
};
}
ConfirmDataFactory.$inject = ['$http', '$q'];
I would like to create a ComboBox with names of all users, but I'm unsure how to do it. (Service is complete)
The cshtml code looks something like this:
<select class="" ng-model="confirmDataForm.city" id="city">
<option ng-repeat="todo in todos">
{{todos.text}}
</option>
</select>
Thank you!