Unable to access Angular Providers in Service Portal

Bryan13
Tera Expert

I am unable to access an Angular Provider in the Service Portal. I tried several OOTB providers just for grins to no avail.

When I add a Provider to the client script:

function ($scope, $http, spUtil, spAttachmentManager) {

and try to access the portal page I get the following error:

Error: [$injector:unpr] Unknown provider: spAttachmentManagerProvider <- spAttachmentManager

Our current build: MID buildstamp: helsinki-03-16-2016__patch7-11-02-2016_11-08-2016_1607

Here is a related thread but I do not see a resolution for the issue:

Using Angular Service Providers in Service Portal

There was an issue opened up on github but closed without resolution: https://github.com/service-portal/documentation/issues/187

Service Portal - Page designer does not play nice with shared services · Issue #187 · service-port...

It details a workaround but I could not get it to work.

try {

angular.module('ng_spd').config(function(lazyLoaderProvider, $provide, $compileProvider, $controllerProvider){

lazyLoaderProvider.set({

register: $controllerProvider.register,

directive: $compileProvider.directive,

factory: $provide.factory,

value: $provide.value,

service: $provide.service

});

});

}catch(e){}

If I use the code as is I get the following error:

Error: [$injector:nomod] Module 'ng_spd' is not available! You either misspelled the module name or forgot to load it.

I am not sure how to add a module to a client script.

If I change the module name to 'sn.$sp', I no longer get the module error but still get the unknown provider error.

Any help would be appreciated.

1 ACCEPTED SOLUTION

Bryan13
Tera Expert

User error...I misread the error message. I was trying to use $scope in a service. I should know better. My Angular is a little rusty.



I removed $scope and everything works fine. Not sure if I should mark this as correct seeing how it was my mistake to begin with.


View solution in original post

5 REPLIES 5

Justin Abbott
Giga Guru

Bryan, could this be because spAttachmentManager is a Directive, rather than a Factory or Service? I think you'd include that in your HTML, rather than in the Client Script.



When I tested this out with another OOTB provider, RPService, it worked just fine.


Actually, that was just a poor example on my part. I originally experienced the issue with a custom Angular Provider service I created.



I get the same error:


Error: [$injector:unpr] Unknown provider: $scopeProvider <- $scope <- spFileUpload


To confirm, you've related your Angular Provider to your Widget using the related list?


Yes.


ang-provider.PNG