I created a simple demo on my PC which is working perfectly fine. However, when I tried to replicate it on jsfiddle to ask a question, I encountered the following error message:
Uncaught Error: [$injector:nomod] Module 'myapp' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
Can someone please explain why this error occurs? I am able to retrieve data on my PC. My main question is how can I refresh or call the same web service after a certain period of time, for example, every 1 minute. In jQuery, we have the setInterval function - how can I achieve this in Angular?
Here is the fiddle: http://jsfiddle.net/acboLcv2/1/
var app=angular.module("myapp");
app.factory('test', function($http) {
//This entire object is returned when the Service runs. It is a singleton
//and its properties can be accessed from any controller
return {
stationDashBoard: function(callback,error) {
$http.get('http://184.106.159.143:8180/FGRailApps/jservices/rest/a/departure?crsCode=VIC').success(callback).error(error);
}
}
});
function departureContrl($scope,test){
$scope.loading=true;
test.stationDashBoard(function(data){
console.log(data);
$scope.data=data.data;
$scope.loading=false;
//alert(data);
},function(error){
alert('error')
}) ;
}
Thanks