
AngularJS Cheat Sheet [pdf] - paulw0
https://dncmagazine.blob.core.windows.net/downloads/AngularCheatSheet-DNCMagazine.pdf
======
lars
This looks like a good resource. But number 28 is wrong:

> Always have a ‘.’ in your ng-models which insures prototypal inheritance.

That isn't what that does. The egghead.io Angular videos also get this wrong.
I really think that the vast majority of Angular programmers don't really
understand how its scoping works. I've ranted about this before [1], it's just
ridiculously complex.

Some scopes inherit prototypically from their parents, and others don't, and
you can't tell or affect it from the markup. The dot just means you're
referring to a property of an object on the scope. If the object is somewhere
in the scope inheritance chain, two directives attached at different points in
that chain can share data by pointing to the object. If the object isn't
there, what the name points to is actually non-deterministic. Ng-model
silently creates it, and the point in the chain at which it creates it depends
on which directive wanted to write to the property, which might depend on the
order in which the user interacts with the different elements on the page.

[1]: [http://larseidnes.com/2014/11/05/angularjs-the-bad-
parts/](http://larseidnes.com/2014/11/05/angularjs-the-bad-parts/)

~~~
aikah
> Whatever the reason is for Angulars popularity, it isn’t that it’s a great
> framework.

Anything that makes programmers productive is a great tool. Angular 1.x
definitely makes teams productive. It's one of the first web framework that
comes with a specific testing framework. The clear separation between the DOM
and the business logic makes apps more testable. And I could go for hours.
Angular helps developers write complex apps faster and better.

Sure it isn't perfect, but show me something better with all the features
AngularJs has.

AngularJS didn't became popular because it was from Google, a simple proof is
the closure widget library nobody uses outside google. AngularJS became
popular because it was obviously superior in term of developer experience.

Now your point about ng-model and scopes is valid.But it's not a angular
problem, it's a javascript issue.Ultimately to understand angular you need to
understand how javascript works, which many develpers don't.

Instead of saying "this thing is bad", Educate them. But I guess
sensationalism drives more clicks.

~~~
lars
I got tons of both hate and love for that blog post. One of the few criticisms
that I can accept is the "The problems are real, but don't matter that much."
view. I don't agree, but I suppose people can have different experiences
there.

Any 'sensationalism' comes from legitimate anger with the framework, after
having spent over a year working with it on a large project.

> Now your point about ng-model and scopes is valid.But it's not a angular
> problem, it's a javascript issue.

This I don't agree with. Yes, JavaScript has prototypical inheritance between
objects, but certainly not between scopes. It has lexical scoping like
everyone else. The decision to have scopes be objects that (sometimes, not
always) inherit from one another, is entirely on Angular. So is the decision
to have ng-model silently create objects on this scope.

~~~
smokeyj
> after having spent over a year working with it on a large project

What issues are you running into? I always hear people complain about angular
but rarely hear why.

~~~
julie1
Most people don't understand directives, so they resort to a pub/sub
communication model that makes the web page unable to scale when you have too
much items that are binded/coupled on a page.

No optimizations are possible for an exponentially resource greedy problem.

------
mberning
I love working with angular, but the intense competition from other
technologies combined with the overall negativity towards it has turned me
off. The long term future of angular seems very uncertain.

~~~
pavlov
Angular 2.0 is the New Coke of web development.

I suspect Google would gain a huge amount of goodwill if they backed down and
announced: "You know, we'll rename the incompatible redesign as AngularNext
0.1 and use it to develop cutting-edge ideas. Then we'll bring the best of
those into the mainstream Angular over time without breaking compatibility."

They could call the rebooted compatible Angular 2.0 "Harmony".

~~~
Bahamut
The Angular team is not going to do backwards compatibility with Angular 1.x
with 2.0 at all - they're going to help with migration some with the router,
but the api are fully incompatible.

FWIW, Angular 2 is awesome to work with, even in its alpha form. Productivity
with it should be immensely improved compared to 1.x.

------
julie1
14 pages for a cheatsheet!

The ones for emacs/vim are 1 page only, I guess we have a measure of the
complication of angular now.

~~~
aikah
Give us a fn break, did you actually read the pdf? that's not a cheatsheet,
more like collection of recipes.

> The ones for emacs/vim are 1 page only,

Apples and Oranges

> I guess we have a measure of the complication of angular now.

AngularJS isn't rocket science. But maybe we don't have the same definition
complexity , which makes sense if you are a skiddie.

~~~
julie1
You are right, I should not compare apple and orange: you can edit text, play
soduku, do syntax highlighting easily, search/replace with regexp in vim,
while in angular JS you can only do slow, unusable data bindings. So comparing
the 14pages of angular sheet is way too much of a disgrace for vim or emacs.

Btw, I use kate that need NO cheatsheets, because mastering an editor does not
make me a better coder...

EDIT: ok I also use vim, emacs, joe, nano, ultraedit, gedit, visualstudio,
netbeans, eclipse, nvi, simpletext, texmate, sublime ... whatever the guy
paying me want me to use even if it is stupid.

------
clement75009
I love cheat sheets! I actually consider them the best way to learn a
framework. This one's excellent. Wish I could find one as good for Meteor.

------
Too
> 24\. Wherever possible, use AngularJS versions of JavaScript functionality.
> So instead of setInterval, use the $interval service....It becomes easier to
> mock them or write unit tests

I've always been very against these angular versions of basic js functions
because it requires everyone on the team to learn them and it puts you even
deeper into the angular lock in swamp, hindering you from eventually changing
your view-framework in the future. Any takes on this?

I like the data binding of angular but try to restrict angular coming in
contact with "core" code. As example we hardly write any services, we just use
them to hold an instance of plain js-classes that can easily be reused in non
angular projects.

~~~
Bahamut
Services such as $interval or $timeout are very simple - $http is also a
fairly simple service to replace too. I don't really view it as much of an
issue when it comes to lock in or migration, there are usually far more
perilous pitfalls when it comes to lack of being able to migrate, such as bad
app architecture or hacks.

------
M8
Sadly will only be valid for ~6 months.

~~~
gooseus
What's happening in 6 months? Is my angular code going to spoil?

~~~
ryannevius
Haven't you heard? All Angular sites are going to self destruct, and the
Github repo will cease to exist.

------
butwhy
Nice domain name.

~~~
meneses
In my opinion this is hosted on Azure and all azure containers have the same
domain name (for obvious reasons).

Nice cheat sheet though!

------
delbel
It'd be nice to see a UI Router cheat sheet in this format as well. I'm always
forgetting nested syntax.

~~~
andyfleming
I would avoid investing too much in UI Router. As soon as the new Angular 2
router is available, it should be used for Angular 1.x projects as well to
support migration to Angular 2 in the future.

------
oi-sendai
Thanks for posting this. Really looking forward to trying out some of the unit
testing advice!

------
hippich
Nice! Perfect addition for my
[http://ihateangular.com/](http://ihateangular.com/) !

~~~
thoman23
You seem to be spending on a lot of energy on your hatred.

~~~
hippich
I am getting enough energy kick from my angular day job on pretty intimate
level :) Also, it serves me as a collection of "gotchas" to point to new devs.

