I am working with a factory that has the function setRoot() defined as shown below, and I need to implement it in my controller.
$scope.testSubmit = testFactory.setRoot();
However, when I open the HTML file containing ng-submit="testSubmit()", the factory function is executed before anything is inputted into the form. How can I properly utilize the factory function within ng-submit?
.factory('testFactory', function($rootScope){
return {
setRoot: function(){
$rootScope.root = 'inside testFactory';
}
}
})