I need to have some global prototype functions on the string class. Eg.
string.prototype.trimWhiteSpaces = function () {
return this.replace(/ +/g, \'\');
I had the urge to prototype some methods too
We're working on a project that uses thousands of classes and members, a large amount of these members are completely repetitive and could be shared among the components
after a few minutes searching I came across these solution Angular Global or Shared Modules
this would happen to any medium to large web application
Angular Docs explained how to do so
Note that This option is different than just any ordinary global module , we want to populate some prototype with our own functionality
This Article Easily Shows how to populate prototypes for our own use inside an Angular App