在函数内部调用函数,但在AngularJS中获取对象未定义

时间:2019-04-09 17:26:44

标签: angularjs rest http

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;
            }
        }

0 个答案:

没有答案