I've been working with a component that I utilized to submit data to the Rest API
. The code snippet for the component is as follows:
(function(angular) {
'use strict';
angular.module('ComponentRelease', ['ServiceRelease'])
.component('createRelease', {
templateUrl: 'components/release/createRelease.html',
controller: CreateRelease,
controllerAs: 'clCtrl',
})
function CreateRelease($http, getReleaseManagers, insertRelease) {
var ctrl = this;
this.$onInit = function() {
getReleaseManagers.promise($http).then(function(response) {
ctrl.managers = response.data.releasemanager;
});
//the save button
ctrl.save = function() {
var release = { "rName": ctrl.r_name, "releaseDate": ctrl.r_date, "releaseSharepoint": ctrl.r_sharepoint, "gManager": ctrl.gname, "pManager": ctrl.pname };
$http.post('http://localhost:8080/post', release).then(function(response) {
console.log("Save in database");
}, function(e) {
console.log(e);
});
};
};
};
})(window.angular);
When I check the console log after saving, I see "undefined" if it was successful and an error message if there were any errors. Is my understanding correct? If the post was successful, shouldn't I see the message "Save in Database"?
I would appreciate your insights on this matter.
I am currently using angularjs 1.6
Thank you for your assistance, Eugen