0

please help here is my code..

var vnotice =[];
  var linkhit = "http://"+ipaddress+"/note.php?action=FullNotice&id="+view;
  //alert(linkhit);
    $http.get(linkhit).then(function (response) {
        vnotice = response.data;

        $scope.vnotice = vnotice;

          filename = response.data.file;
    })

alert(filename);

Here help me to get filename from array .. i was trying

var filename = response.data.filename;

but its not working.. please help.

  • 1
    Put your alert **inside** the callback function. Then read http://blog.ninja-squad.com/2015/05/28/angularjs-promises/, because you're not understanding the principle of asynchronism. – JB Nizet May 06 '17 at 13:18
  • Also a terrible practice using global variables like the way you are using `filename ` – charlietfl May 06 '17 at 13:22

0 Answers0