Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

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

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.