I am trying to set up Angular2 in an existing application which uses prototype.js. But looks like Angular2 also has dependency on prortotype.js (correct me if I am wrong) and hence throws a "maximum call stack size exceeded RangeError(in Chrome)"
when trying to load the app. I am pretty new to Angular2.
I could reproduce it in the Angular2 quick-starter app by adding the prototype.js dependency.
<!DOCTYPE html>
<html>
<head>
<title>Angular QuickStart</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<base href="/">
<link rel="stylesheet" href="styles.css">
<!-- Polyfill(s) for older browsers -->
<script src="node_modules/core-js/client/shim.min.js"></script>
<script src="node_modules/zone.js/dist/zone.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<script src="systemjs.config.js"></script>
<script>
System.import('main.js').catch(function(err){ console.error(err); });
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prototype/1.6.0.3/prototype.js"></script>
</head>
<body>
<my-app>Loading AppComponent content here ...</my-app>
</body>
</html>
The partial stack trace in the web inspector console is:
Error: (SystemJS) Maximum call stack size exceeded RangeError: Maximum call stack size exceeded at ParamDecoratorFactory (http://localhost:3000/node_modules/@angular/core/bundles/core.umd.js:401:39) at new (https://cdnjs.cloudflare.com/ajax/libs/prototype/1.6.0.3/prototype.js:214:23) at ParamDecoratorFactory
I am doing something wrong? or if not, is there a work around for it?
Thanks in advance!
Go to the file for prototype.js
.
Add
var bindTemp = Function.prototype.bind;
at the beginning of the file.
Add
Function.prototype.bind = bindTemp;
at the end of the file. It should work now.
Credits: Solution