Angular JS error var Undefined

Asked

Viewed 86 times

0

Good night have that function https://pastebin.com/mZB1KtnS if I give an Alert(date); inside the function (below the date) ok, but I invoke the function in the Undefined controller. How can I fix it? thank you

1 answer

0

$scope.convertMd5 = function (string) { // retorna string em md5
    return $http({
        method: 'POST',
        url: '../assets/php/client/Users.php',
        data: {ref: 'convert-md5', str: string},
        dataType: 'html',
    });
}
$scope.convertMs5('aaaa').success(function (data) {
        //o que quer fazer
    });

$http works async, what happens is that the Sl variable has only been set but no value and Fc returns before the $http response.

  • Rodolfo I need to return the value date. How would I do it? If I put Return data, give the same error...

  • if you are going to use within $Scope is just treat within Success and assign to $Scope, if you are going to use for another $http call put inside the Success, that is, what you have to do will do inside the Success

  • How would I return the date? For I will invoke it within another function...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.