-1
$http({
    url: "php/InsertTab.php",
        method: "POST",
        data: {
            'userId': userId,
        },
        headers: {'Content-Type': 'application/x-www-form-urlencoded'}
        }).success(function(data, status, headers, config) {

        myVar = data;

        }).error(function(data, status, headers, config) {
    });

console.log(myVar);

can variable myVar be share / be access outside the scope of $http? I wrote console.log(myVar) outside it returned blank?

1 Answers1

0

u have to use angular $q service in order to use myVar outside of $http. try reading in this page : https://docs.angularjs.org/api/ng/service/$q

Tomer Pearl
  • 107
  • 9