angularJs的新手。我想在方法内部调用$ http.post(),并在方法完成后再次调用它,但是在设置标识符
时将emailAttributeObject设为未定义public sendEmail() : angular.IPromise<any> {
var isRequestUpdated = this.setEmailAttributes();
if (isRequestUpdated) {
let deferred: angular.IDeferred<any> = this.$q.defer();
var url = window.location.href.replace("/self-service/app/editData", "/security-service/sendEmail/emailAttributes");
this.$http.post(url, this.emailAttributeObject).then(
function successCallback(response) {
this.emailAttributeObject.emailAttributes['employeeMailIdentifier'] = 'mailIdentifier';
this.$http.post(url, this.emailAttributeObject).then(
function successCallback(response) {
this.$log.debug("Successfully POST-ed data");
deferred.resolve();
}
);
this.$log.debug("Successfully POST-ed data");
deferred.resolve();
},
function errorCallback(response) {
this.$log.error("POST-ing of data failed");
deferred.reject();
}
);
return deferred.promise;
}
}