I am trying to utilize Javascript functions outside the controller in Angular JS instead of using a service within a module. Is this allowed?
For instance:
var UrlPath="http://www.w3schools.com//angular//customers.php"
//this section will store all the functions
function testing_Model ($http){
var self=this;
self.getRecords=function(){
$http({
Method:'GET',
URL: UrlPath,
}).success(function(data){
self.record=data.records;
});
}
self.getRecords();
}
angular.module("myApp", []);
app.controller('myController', function ($scope, $http) {
$scope.testing_Model = new testing_Model();}
Upon running the above code, I encountered an error stating "$http is not a function".
I appreciate any assistance provided.