Angular JS : Uncaught Error: [\$injector:modulerr]

nthumma
Giga Guru

I am trying to do simple Rest Calls using angularjs posted here , it works fine if i select direct check box on the UI Page.

below is the error i am getting on console

i copied this angular version https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js

AngularjsError.JPG

any thoughts? I am trying it on Helsinki.

1 ACCEPTED SOLUTION

dave_slusher
ServiceNow Employee
ServiceNow Employee

If you are going to use John's example, I think you will need to back up your angular version to closer to what he has. I think 1.5 will have problems with this. I logged onto to your developer instance to run this and if you click the link in that error, you get the below. It looks like some kind of incompatibility between Angular and Prototype.



Using angular this way is definitely the hard way. You have a Helsinki instance, I'd suggest you put your energy into Service Portal widgets rather than this style. This is how you had to do it pre Helsinki but your life is much easier if you let the system handle all the boiler plate for you.



Failed to instantiate module ng due to:


TypeError: Cannot set property 'aHrefSanitizationWhitelist' of null


  at oe (https://dev22202.service-now.com/scripts/js_includes_customer.jsx?v=04-21-2016_1541&lp=Sun_Jul_10_06...)


  at new <anonymous> (https://dev22202.service-now.com/scripts/doctype/js_includes_doctype.jsx?v=04-21-2016_1541&lp=Sun_Ju...)


  at Object.instantiate (https://dev22202.service-now.com/scripts/js_includes_customer.jsx?v=04-21-2016_1541&lp=Sun_Jul_10_06...)


  at c (https://dev22202.service-now.com/scripts/js_includes_customer.jsx?v=04-21-2016_1541&lp=Sun_Jul_10_06...)


  at https://dev22202.service-now.com/scripts/js_includes_customer.jsx?v=04-21-2016_1541&lp=Sun_Jul_10_06...


  at r (https://dev22202.service-now.com/scripts/js_includes_customer.jsx?v=04-21-2016_1541&lp=Sun_Jul_10_06...)


  at Object.provider (https://dev22202.service-now.com/scripts/js_includes_customer.jsx?v=04-21-2016_1541&lp=Sun_Jul_10_06...)


  at https://dev22202.service-now.com/scripts/js_includes_customer.jsx?v=04-21-2016_1541&lp=Sun_Jul_10_06...


  at Object.invoke (https://dev22202.service-now.com/scripts/js_includes_customer.jsx?v=04-21-2016_1541&lp=Sun_Jul_10_06...)


  at d (https://dev22202.service-now.com/scripts/js_includes_customer.jsx?v=04-21-2016_1541&lp=Sun_Jul_10_06...


View solution in original post

11 REPLIES 11

dave.slusher   you meant like this?



jsnewtab.JPG


dave_slusher
ServiceNow Employee
ServiceNow Employee

If you are going to use John's example, I think you will need to back up your angular version to closer to what he has. I think 1.5 will have problems with this. I logged onto to your developer instance to run this and if you click the link in that error, you get the below. It looks like some kind of incompatibility between Angular and Prototype.



Using angular this way is definitely the hard way. You have a Helsinki instance, I'd suggest you put your energy into Service Portal widgets rather than this style. This is how you had to do it pre Helsinki but your life is much easier if you let the system handle all the boiler plate for you.



Failed to instantiate module ng due to:


TypeError: Cannot set property 'aHrefSanitizationWhitelist' of null


  at oe (https://dev22202.service-now.com/scripts/js_includes_customer.jsx?v=04-21-2016_1541&lp=Sun_Jul_10_06...)


  at new <anonymous> (https://dev22202.service-now.com/scripts/doctype/js_includes_doctype.jsx?v=04-21-2016_1541&lp=Sun_Ju...)


  at Object.instantiate (https://dev22202.service-now.com/scripts/js_includes_customer.jsx?v=04-21-2016_1541&lp=Sun_Jul_10_06...)


  at c (https://dev22202.service-now.com/scripts/js_includes_customer.jsx?v=04-21-2016_1541&lp=Sun_Jul_10_06...)


  at https://dev22202.service-now.com/scripts/js_includes_customer.jsx?v=04-21-2016_1541&lp=Sun_Jul_10_06...


  at r (https://dev22202.service-now.com/scripts/js_includes_customer.jsx?v=04-21-2016_1541&lp=Sun_Jul_10_06...)


  at Object.provider (https://dev22202.service-now.com/scripts/js_includes_customer.jsx?v=04-21-2016_1541&lp=Sun_Jul_10_06...)


  at https://dev22202.service-now.com/scripts/js_includes_customer.jsx?v=04-21-2016_1541&lp=Sun_Jul_10_06...


  at Object.invoke (https://dev22202.service-now.com/scripts/js_includes_customer.jsx?v=04-21-2016_1541&lp=Sun_Jul_10_06...)


  at d (https://dev22202.service-now.com/scripts/js_includes_customer.jsx?v=04-21-2016_1541&lp=Sun_Jul_10_06...


dave.slusher,


Thanks,its working after changing angular version to 1.4.


hi,


can you check what i wrote in response to that question? if it good enough?



thanks,


Rivki Aizen | GRTH | Amodcs


rivkiaizen_grth
Kilo Explorer

Hi,


i had the exact error!


I found a solution for that, i'll happy to hear if it good enough or there is a better solution?



I found that there is basic function of javascript: Function.prototype.bind, which servicenow override it.


I must use the original bind function, so what i did is : I saved the bind function of servicenow in temp variable, and rewrite bind function of javascript,


and when i needed to use "script include" functions: i restored bind function of service now, and then used servicenow function , and then again rewrite the bind function of javascript:



for example:( saved the bind function of servicenow in temp variable, and rewrite bind function as javascript)


find_real_file.png



var bindTemp=Function.prototype.bind;


  Function.prototype.bind = function(oThis) {


  if (typeof this !== 'function') {


    // closest thing possible to the ECMAScript 5


    // internal IsCallable function


    throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable');


  }


  var aArgs     = Array.prototype.slice.call(arguments, 1),


  fToBind = this,


  fNOP       = function() {},


  fBound   = function() {


    return fToBind.apply(this instanceof fNOP


  ? this


  : oThis,


  aArgs.concat(Array.prototype.slice.call(arguments)));


  };


  if (this.prototype) {


    // Function.prototype doesn't have a prototype property


    fNOP.prototype = this.prototype;


  }


  fBound.prototype = new fNOP();


  return fBound;


    };





before using servicenow function   i restored bind function of service now, and then used servicenow function , and then again rewrite the bind:



find_real_file.png


Function.prototype.bind=bindTemp;


  var ga = new GlideAjax('GIC_helper');


  ga.addParam('sysparm_name','getAccounts');


  ga.getXMLWait();


  var list =ga.getAnswer();


  list=JSON.parse(list).result


  Function.prototype.bind=temp;



Best Regards,


Rivki Aizen | GRTH