Reputation: 4115
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");
});
}
...
Upvotes: 0
Views: 775
Reputation: 33191
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
.
Upvotes: 5