please check it here: http://jsfiddle.net/9VaW2/1/
I want jData be available outside
$http({method: 'POST', url: '/someurl'}).
success(function(data, status, headers, config) {
var jData = data;
}).
error(function(data, status, headers, config) {
});
but when I do this
$view.availableData = {
cols:{ID:'ID', Date:'Date'},
rows:{data:jData},
options:{}
};
it gives me this error
ReferenceError: jData is not defined
EDIT update fiddle
http://jsfiddle.net/9VaW2/3/
** I think I found a solution to make a syncronus call ..async : false. that works. I think the page was loading faster than the data was coming back....wonder if someone has a better solution **
Just define as a global variable.
var jData;
$http({method: 'POST', url: '/someurl'}).
success(function(data, status, headers, config) {
jData = data;
}).
error(function(data, status, headers, config) {
});
$view.availableData = {
cols:{ID:'ID', Date:'Date'},
rows:{data:jData},
options:{}
};