i want to share data that i get from the lastFM API between two controllers.
I've been trying with the factory but I don't get a grip on it...
angular.module('myApp')
.factory('getData', function($http, $scope, $routeParams) {
$http.get(lastfm + "&method=artist.getInfo&mbid=" + $routeParams.mbid).success(function(data) {
console.log(data)
});
})
.controller('artistCtrl', function ($scope, $routeParams, $http, getData) {
console.log(getData.data);
})
.controller('artistInfoCtrl', function ($scope, $routeParams, $http, getData) {
console.log(getData.data);
})
So how do i manage to pull this off?