0
save = () => {
            for (var j = 0; j < this.templatetypes.length; j++) {
                this.template = this.templatetypes[j];
                this.smsTemplate.Template_Type_LSeq = this.template.value;
                this.smsTemplate.SmsCode = this.template.smsCode;
                this.smsTemplate.SmsName = this.template.smsName;
                this.smsTemplate.SmsMessageTemplate = this.template.smsFormat;
                this.smsTemplateSvc.postSmsTemplate(this.smsTemplate).then(() => {
                    return;
                });
            }                      
        }

Blockquote it only pauses the last value for 4 post

1 Answers1

0

You can't really pause the controller in an ajax call. You can have a callback method which will process the returned response.

This line here is wrong.

 this.smsTemplateSvc.postSmsTemplate(this.smsTemplate).then(() => {
      return;
 });

You are doing a return in the .then() promise so as soon as .postSmsTemplate() resolves, it does a return and exits immediately.

https://docs.angularjs.org/api/ng/service/$http has more information on it.

A good example here: How to wait till the response comes from the $http request, in angularjs?

Community
  • 1
  • 1