I've been avoiding even thinking about the latest rev of Angular as every time I did look at it, I came away with a headache. It was weird and the docs were even weirder. I saw plenty of blog posts on the topic, but in general they dealt with one small slice of Angular 2 and were too confusing for me to grok.
Over the holidays, I checked out the web site again (Angular 2 can be found at https://angular.io/ whereas Angular 1 is still at the old site: https://angularjs.org/). I tried the five minute quick start and while it took me a bit more than five minutes, it made a bit of sense. It certainly wasn't crystal clear to me, but it wasn't crazy either.
I then went through the tutorials and things began to make even more sense. I'm far from being even close to being able to build a demo with it, but the basics are beginning to click for me.
There were three things in particular I ran into that caused me grief.
-
Working with Angular 2 means working with TypeScript. I like TypeScript. But I'm kinda disappointed that working with Angular now means working with a build system to get it into the browser. To be absolutely clear, I'm not saying this is bad. I'm just saying I feel a bit disappointed that this is required now. I'll get over it.
-
The @Component stuff was terribly confusing to me until it finally sank in that those blocks are providing metadata to the classes. It seems so obvious now, but I just couldn't understand what in the heck stuff like this was doing:
import {Component} from 'angular2/core';
@Component({
selector: 'my-app',
template: 'My First Angular 2 App
'
})
export class AppComponent { }
- One thing I really didn't like in Angular 2 was all the different types of "syntax sugar" being used in templates. Here are just a few examples:
[(ngModel)]="foo.name"
and*ngFor
and(click)="something"
. I figured there was no way in heck I'd be able to get that right. Luckily - there's a great cheat sheet that nicely documents all this and is easy to use.
So what's next? I plan on making my way - slowly - through the rest of the docs. I'm also going to reread the tutorials a few times. I then need to make the time to look at Ionic 2.
For a while now I've been telling people that - at least in my opinion - it was too early to start playing with Angular 2. Now I definitely feel like it would be a great time to start playing with it and - possibly - even building real apps with it. I'd love to know what my readers think so leave a comment below. Are you using Angular 2 yet or have you been holding off?
Archived Comments
We've switched to using React/Flux for new projects and are much happier for it.
I looked at React too but it doesn't quite feel right. Not yet anyway.
I'm hooked. It's the most excited I've been about a new technology since Node. React Native also has great potential but isn't ready for prime time yet. But React itself flies and is incredibly stable. YMMV obviously, but the virtual DOM and component nature of the framework means you're productive quickly and your UI logic is insanely simple.
It seems to me like you don't have to use Typescript. https://angular.io/docs/js/...
Would I sound dumb if I said I didn't even notice the drop down?
haha that's ok. I don't think I saw it right away either.
Initially I was questioning Typescript too but now I wouldn't do a project with out it. It is has really helped some of the junior devs I have worked with write better JS code via the TS compiler. It has also helped me learn the AngularJS API (both 1.0 and 2.0) with the nice code complete you get in VS Code or Webstorm/IntelliJ.
"Working with Angular 2 means working with TypeScript"
Errr...the developers of Angular 2 suggest it, but it is 100% usable with Javascript.
Yep - I was wrong. Someone else pointed it out in the comments below. :)
I don't see how the new features really add anything. I wish the developers had concentrated on completely removing (100%) the need to use JQuery. The new Angular is still nothing more than a bloated JQuery container
Curious - why do you say "need to use jQuery" - I rarely, if ever , use anything jQuery related in my Angular apps.
Don't you use directives? Most directives are nothing more than JQuery containers. Less than 10% of the code and more than 90% of the problems. The effort expended on Angular 2 would have been better spent removing that last little bit and becoming 100% virtual instead of dependent in any way on the browser.
I guess I'm revealing my ignorance then. I use directives a bit - have written one - but I didn't think that was jQuery itself. I seem to remember reading that Angular included a stripped down version of jQuery internally, but that it wasn't exposed.
Built my first larger application with Ng2 and love it like crazy.
One quick comment: the "banana in a box" notation (2way binding) is to be avoided if you can.
I'm in love with Observables, they are so powerful that is is a total game changer for me.
Who uses JQuery?
Where do you see any jQuery references?
What does that have to do with the Angular2 framework?
You can also use Angular2 with Redux.... it's really independent on the framework you use... or library (in the case of React). But I*m with you, I like the Angular approach much more.
To me it seems more close to Scientology than anything else.
For example: Flux has nothing to do with React. But React developers always sound like it only works with React.
You're comparing a library that has been in v. 1 for a year, with a framework that just came into beta? And then you praise the "component nature of the framework", knowing that Angular also uses this structure? (plus much much more).
There are too many things that React cannot do and you're ending up using a myriad of libraries to complement it imho.
Also, the core Angular team is way nicer than then React ditto :)
Ideally you use templates instead of direct DOM manipulation in your directives. There are very few problems that can't be solved using templates. $ is a last resort (but still useful) or you can just use DOM scripting for the occasional direct manipulation that's required.
You can write it in plain ES5, but your life will be less fun if you do so.
You can write it in ES6/ES7 and your life will be fun again :)
I'm digging parts of ES6/7 so far - and others are confusing. It will come in time.
Directives are not jQuery. You are allowed to use jQuery in your link function in a directive, but it's a last resort thing. You'll only need it for your most complex components. Templates are the right way.
I think TypeScript probably shows its power in a larger team of mixed ability developers. For a lone dev, or a small team, strong typing seems like overkill.
The JavaScript documentation is several steps behind, and often out of date. Decent JavaScript documentation is still hard to come by at this point in time. I'm sure this will change. I'm working on a set of JS Angular2 docs at the moment, similar to the series I built for Angular 1.
Actually, I retract this comment. You can write fun Angular in ES5 / ES6 or ES7.
This article talks a lot about issues with digest/scope, and I can say I ran into that a lot with Angular1. I just assumed it was always my fault, but it was probably my main annoyance with Angular 1. I haven't seen that once with Angular 2. :)