r/angularjs • u/superluminary • Feb 26 '16
How to do Everything in Angular 2 using vanilla ES5 or ES6
http://nicholasjohnson.com/blog/how-to-do-everything-in-angular2-using-es6/1
u/superluminary Feb 26 '16
Many early tutorials suggested manually decorating your objects, or manually interacting with the injector. None of this is necessary in the current build.
1
0
Feb 29 '16
[deleted]
1
u/superluminary Feb 29 '16
Angular 2 doesn't have a built in module system. Instead you are expected to pick an off the shelf module system, such as SystemJS or RequireJS.
These essentially just create IIFEs, and then expose objects as local variables inside them using the
requirefunction.You might even just create a global singleton app object and hang everything off that: var app = {CatComponent: ....}, This would work just as well.
I didn't do that in these examples because I wanted to show how simple and JavaScripty Angular 2 code can be. Global namespacing is not required.
4
u/[deleted] Feb 26 '16
Interesting. I think Typescript might not have been the best choice for Angular2.
It could hurt adoption.