I have a controller, and a factory that is using the controller's functions. The reason I do this, is because I want to use some functionalities in more controllers, depending on the actual $scope
My solution would be something lik the code below. However, angular throws an error saying controllerFunction is undefined
EDIT: This code is working! I made a typo somewhere else in the code.
angular.module('myApp')
.controller('myController', function ($scope, $http, myInterface) {
var myFactory = new myInterface($scope);
$scope.controllerFunction = function(){
// do something
}
})
.factory('myInterface', function(){
var self;
function Interface($scope) {
this.$scope = $scope;
self = this;
}
Interface.prototype.interfaceFunction = function(){
self.$scope.controllerFunction();
}
return Interface;
});
controllerFunction()function to an specific service.. Than you can use it everywherefactorythat calls a function fromController1and then call this factory-function inController2