0

I have a http service where im attempting to save the result to a scope variable, but the debugger keeps returning that the variable does not exist.

Here is the code.

...
$scope.valueList = [];
$scope.getValues = function() {
        $http({
            url: '/restservice/values/',
            method: 'POST',
            data: this.json_data,
            headers: {'Content-Type':'application/json'}
        }).success(function (data, status, headers, config){
            this.valueList = data;
        }).error(function (data, status, headers, config) {
            console.log("Failed"); 
        });
}
...

1 Answer 1

5
this.valueList = data;

Should be

$scope.valueList = data;

Angular is still Javscript, so this context scope still apply. Also, this in this case does not equal $scope.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.