angular 1.6 - post request does not show DIV

0

I am presenting a problem at the front level when making a request to a REST webservice, with the POST method, by clicking on the button, it is executed successfully, I get the response from the api, the same answer must show me a DIV with the message of "successful registration", I made a debug, and in effect the response travels to the point where it should show the message, but it does not, it is as if the view was not built, it should be highlighted that if I give two clicks to the button next if the message appears on the front

here is my code in the controller

           insertFactByCategory.insertFacts(data,$rootScope)
           .success(function(success){
               console.log(success);
               vm.validateMessage(success);
           })
           .error(function(error){
              console.log(error);
           });

code in the factory service in angular

        function insertFacts(data,$rootScope){
        return $.ajax({
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded'
            },
            url: $rootScope.domainUrlHebdoConf+'/semana/insert/category',
            method: "POST",
            data: data
        });

I remain attentive to your comments and / or suggestions

    
asked by Jdeveloper 02.03.2018 в 14:05
source

1 answer

0

The problem is in the angular binding.

When making the call with Jquery everything works fine, but angular does not trigger the refresh of the data because they are being performed "inside Jquery".

Change the $ .ajax call to:

 return $http.Post($rootScope.domainUrlHebdoConf+'/semana/insert/category', data);

($ http: link $ http # post))

This way, when the angular success is executed, it will correctly update the div.

Remember that you must inject the $ http module in your factory to be able to use it.

    
answered by 10.06.2018 в 19:50