This is the first interaction with angularjs. it's first time. how can I call the function and get the items now in another controlers ?
I am loading CSV file using AngularJS
var Mymodule = angular.module('Mymodule', []);
Mymodule.factory('Items', ['$http', function($http){
var Url = "data/ex.csv";
var Items = $http.get(Url).then(function(response){
return csvParser(response.data);
});
return Items;
}]);
I need to get returned values to do some filtering on the data I have ?
function doSomethingWithRows(rows) {
//Mymodule.Items
// How to call data here.
}
UPDATE Based on first answer
<script>
var Mymodule = angular.module('Mymodule', []);
Mymodule.factory('Items', ['$http', function($http){
var Url = "data/ex.csv";
var Items = $http.get(Url).then(function(response){
return csvParser(response.data);
});
return Items;
}]);
var $injector = angular.injector();
$injector.invoke(['Items', function(Items){ console.log(Items) }]);
</script>
error:
Uncaught Error: Unknown provider: ItemsProvider <- Items
doSomethingWithRows(in a controller, service, etc.?). In AngularJS you use dependency injection for such things.