Exploring the world of AngularJS for the first time and seeking guidance on calling a function to retrieve items in different controllers.
Incorporating CSV file loading 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;
}]);
Looking to obtain the returned values for data filtering purposes?
function doSomethingWithRows(rows) {
//Mymodule.Items
// How to call data here.
}
UPDATE Based on initial response
<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