I have a very basic factory and controller in AngularJS, took it from another post on Stack Overflow
var app = angular.module( 'testapp', [] );
app.factory('commonService', function ($scope) {
var obj= {};
obj.func = function () {
console.log('route 1');
}
obj.func1 = function () {
console.log('route 2');
}
return obj;
});
app.controller('FirstController', function ($scope, commonService) {
console.log('route 1' + commonService.func());
});
app.controller('SecondController', function ($scope, commonService) {
console.log('route 2' + commonService.func1());
});
For some reason this keep giving me the error Unknown provider: $scopeProvider <- $scope <- commonService
I am trying to use a factory in order to clean up my code and re-use some functions in my controller; I have tried using a service and had the same results.