Re: [AngularJS] Convert Angular $http post to async

11 views
Skip to first unread message

András Csányi

unread,
Jul 26, 2016, 7:59:37 AM7/26/16
to ang...@googlegroups.com
Hi,

It is already asynchron from your client application viewpoint. What other asynchronicity you would like to achieve?

Thanks,

András

- -
--  Csanyi Andras (Sayusi Ando)  -- http://sayusi.hu -- http://facebook.com/andras.csanyi
--  ""Trust in God and keep your gunpowder dry!" - Cromwell

On 26 July 2016 at 08:52, Frijx Frijx <frij...@gmail.com> wrote:
Hi all,

I'm trying to convert the following post to async, I dont know if anyone could possibly help me ?

angular.module('testAsync').controller('ContactController', function ($scope, $http) {
    $scope
.sendMail = function () {
        document
.getElementById("info").innerHTML = "Sending, Please Wait...";
        document
.getElementById("sendThatMail").style.visibility = "hidden";
        document
.getElementById("sender").style.visibility = "visible";
       
var data = $.param({
            emailAddress
: $scope.emailAddress,
            emailMessage
: "--- Name : " + $scope.myName + "--- Email Address : " + $scope.emailAddress + "--- Msg : " + $scope.myMsg,
            emailSubject
: $scope.mySubject
           
//emailName: $scope.myName
       
});
        $http
.post("api/SendMail", data, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }).success(function (data) {
            $scope
.results = data;
            document
.getElementById("info").innerHTML = data;
            document
.getElementById("sender").style.visibility = "hidden";
            document
.getElementById("sendThatMail").style.visibility = "visible";
       
}).error(function () {
            alert
("error");
            document
.getElementById("sender").style.visibility = "hidden";
            document
.getElementById("info").innerHTML = "Error Sending, Please try again...";
            document
.getElementById("sendThatMail").style.visibility = "visible";
       
});


   
};
});

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages