Eka Rudianto
Eka Rudianto

Reputation: 4755

Uncaught TypeError : undefined is not a function & Uncaught RangeError : maximum call stack size exceeded Angular2

I've been following the Angular2 quicstart using javascript in the purpose of learning the Angular2 framework.. I've been doing exactly like the guidelines told me but I'm having an errors

Uncaught TypeError: undefined is not a function angular2-all.umd.js:3528
Uncaught RangeError: Maximum call stack size exceeded angular2-polyfills.js:143

I'm not sure if I missed something, this is the file structure of my app

and this is the code base

app.component.js

(function (app) {

    app.AppComponent = ng.core
        .Component({
            selector: 'my-app',
            template: '<h1>My First Angular 2 App</h1>'
        })
        .Class({
            constructor: function () {
            }
        });

})(window.app || (window.app == {}));

boot.js

(function(app) {

    document.addEventListener('DOMContentLoaded', function() {
        ng.platform.browser.bootstrap(app.AppComponent);
    });

})(window.app || (window.app = {}));

index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Angular 2</title>

    <script src="node_modules/angular2/bundles/angular2-polyfills.js"></script>
    <script src="node_modules/rxjs/bundles/Rx.umd.js"></script>
    <script src="node_modules/angular2/bundles/angular2-all.umd.js"></script>

    <script src="app/app.component.js"></script>
    <script src="app/boot.js"></script>

</head>
<body>
    <my-app>Loading..</my-app>
</body>
</html>

I think I followed the quickstart perfectly, but I'm not sure on where did I missed since I'm new to Angular2

Upvotes: 2

Views: 764

Answers (1)

dfsq
dfsq

Reputation: 193301

You have a little almost unnoticeable typo in your code that makes a huge difference. This is your IIFE in app.component.js file:

(function (app) {
    // ...
})(window.app || (window.app == {}));
// comparison operator ------^

Note, that you use comparison operator, while you want assignment:

(function (app) {
    // ...
})(window.app || (window.app = {}));

Upvotes: 1

Related Questions