Using AngularJS $http: the WRONG way.
/**
* Register factory for `stockService` instances.
*
* Note: the getStocks() expects a callback function used to notify
* the caller when the data is ready.
*
* !! This is BAD !!
*/
angular.factory('stockService', function($http)
{
return {
getStocks: function(callback)
{
$http
.get('stocks.json')
.success( function(data)
{
// initiating callback with data
callback(data);
});
};
};
};