I'm encountering an issue where I am attempting to utilize a function as a constructor inside the `.provider`, but I'm unable to instantiate a new constructor when it's within the `$get`.
Here is my provider setup -
this.$get = $get;
$get.$inject = ['checkUrl', '$log', '$location'];
function $get(checkUrl, $log, $location) {
return {
moduleCon: function(name, cb) {
//my constructor function
}
}
When I try to inject and call it like this
new myProvider.$get().moduleCon("name", "cb");
I encounter an injector error.
However, if I move it outside of the $get, it works as follows:
(inside the provider above the $get)
this.moduleCon = function(name, cb) {
//my constructor function
}
I need to use `this.`, but then I can successfully call
new myProvider.moduleCon("name","cb");
And it works correctly. Is there any way to expose it in the $get as a constructor as I am doing here? Thank you!