我需要在字符串类上有一些全局原型(prototype)函数。例如。string.prototype.trimWhiteSpaces=function(){returnthis.replace(/+/g,'');}我正在使用AngularCLI,我希望我的Angular4应用程序中的所有字符串都可以访问此函数。我已将代码片段添加到名为prototypes.js的文件中,并在.angular-cli.json中加载了该文件"scripts":["assets/js/prototypes.js","../node_modules/jquery/dist/jquery.min.js","../