In the controller i would like to put the http request of a json file into a function. Only when its outside of a function it works. Why? I would like to display the contents in the view.
Controller:
$http.get('components/json/list.json').success(function (data) {
main.listNoFunction = data;
});
main.listFunction = function () {
var result = null;
$http.get('components/json/list.json').success(function (data) {
result = data;
});
return result;
}
View:
// This works:
{{ main.listNoFunction }}
// This works NOT:
{{ main.listFunction }}
Thanks for your help! Vin