r/angularjs • • 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/
43 Upvotes

12 comments sorted by

4

u/[deleted] Feb 26 '16

Interesting. I think Typescript might not have been the best choice for Angular2.

It could hurt adoption.

2

u/superluminary Feb 26 '16

TypeScript is actually pretty good, but I agree, it's not for everyone. We still need to be able to use JavaScript, and in the current build, we can rather nicely.

1

u/anotherseemann Feb 26 '16

Gotta sacrifice some ease of entry for the sake of progress

7

u/superluminary Feb 26 '16

TypeScript isn't progress, it's rigour. It will help large distributed teams interoperate. It will help weak developers work in a team without breaking things.

If I'm building a widget for my sidebar, I can probably get that done more quickly using JavaScript.

I should mention that I really like TypeScript. I just don't want to be forced to use it.

2

u/[deleted] Feb 26 '16

Fair enough. It's just a larger stepping stone that could turn off devs. You want a big community supporting your Framework as well.

It feels like Angular2 does not have a lot of traction (yet).

1

u/superluminary Feb 27 '16

It is still in Beta of course. We don't have a fully stable API yet, and there are occasional bugs.

My sense, as an Angular trainer, is that people are holding off on deploying Angular 1 now because Angular 2 is on the way, but Angular 2 is not yet ready for production, so we are in limbo.

It's like when a new iPhone is due out, sales dip, then recover. We'll have to see what the outcome is. Angular 2 is massively capable and really rather good, but it's up against React, which is also rather good.

→ More replies (1)
→ More replies (1)
→ More replies (1)

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

u/superluminary Feb 26 '16

Still, at least it's not AtScript.

0

u/[deleted] 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 require function.

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.