Hacker News new | past | comments | ask | show | jobs | submit login
AngularJS Tutorial: A Comprehensive 10,000 Word Guide (airpair.com)
173 points by toddmotto on Oct 6, 2014 | hide | past | favorite | 22 comments



I would love to see a section on authentication and authorization best practices. From my research, it doesn't seem like this is covered as well as it should be in various Angular resources. This isn't a knock against the OP - just something I'd like to see.


Authentication and Authorization don't belong in the front-end, that belongs on the backend with the server, the one true source as to whether a user is authenticated and whether a user has authorization to do what they are trying to do.

So as long as you write your REST endpoints correctly, your front-end will fall into line.


I agree that most of the authentication belongs on the backend, but there's still the question of how best to handle/recognize authenticated users and authorized requests on the frontend. Should I be using JSON web tokens, or cookies? What's the best way to protect routes for users with varying degrees of access? If anything, I'd like to see pros and cons of each strategy, assuming a backend implementation is already in place.


> your front-end will fall into line.

How, exactly? Basic auth? Cookies? Tokens? OAuth?

There are lots of ways to do this, and I agree with your parent that if there is a best practice, it isn't obvious or well-known.

Edit: Ignore this - posted at the same time as arms!


This is what we've been doing at my workplace, we're a Google partner so all Auth is done through Google.


Feedback really welcome, looking to expand this guide to include testing and other Angular features :)


Awesome guide Todd -- thank you so much for taking the time to put this together (I know how scarce time can be, and I also know how much time goes into a 10k-word tutorial, so it's appreciated).

I went through the whole thing last week when it went live, and right off the top of my head, my biggest piece of feedback is that there are several sections where ideas/concepts are introduced without enough context. I've been playing with Angular for a few months so have a baseline of knowledge, but I know that were I a newbie, some things would be confusing.

The first example that stuck out is in section 4 ('Understanding $scope'). That paragraph mentions Controllers several times, and refers to some code that includes the ng-controller directive. But Controllers aren't introduced until section 5.

So as someone who likes to fully understand each block of example code I'm presented, that would likely be confusing if I hadn't already known what Controllers were. So in that section, maybe a bit of re-ordering / introduction is called for.

(Perhaps you can find a "pure novice" out there who will volunteer to read the whole thing over and highlight where that sort of thing happens.)

Many thanks again for putting this together!


I'm always surprised to see methods declared in the constructor.

I get that you prefer to do that for a controller exposed in the scope but why not use the prototype for a service ?


You should provide great sources for AngularJS plugins/modules to prevent implementing our own, and reinventing the wheel, Also could cover in a chapter how to extend AngularJS with similar stuff. I'd love to read about handling producer side of message queues.


Great tutorial. Good overall guide vs. many I have read that go over most of the basic Angular starter points.

I have a question about the syntax you are using for factories and services. I notice you use Pascal Case for your objects vs. Camel Case as in the AngularJS docs... I like to use best practices and have seen both so I am not sure which is kosher in the community. Is that something that is changing?

I noticed you define it as a function first then reference it in the constructor. I understand what you are doing but again the examples I have seen do it differently so I am confused as to which way to do it and the "why".


What about a piece on best practices and suggestions on things to do and watch out for? I know as someone just getting into angular that would be nice to know before I make the same mistakes.


Todd has already mentioned his Best Practices guide, which is awesome and inspired me to write my own. Mine is heavily based on his, but adds a few more (maybe controversial) things. And I have a sample seed project that implements many of the best practices. See https://github.com/jmcunningham/angularjs-styleguide


Great idea - it's all well learning the concepts/APIs but putting them into good practice is great. I think a section on this would be perfect!


Todd Motto also has a great style guide, as well, that could be used as sort of a best practices: https://github.com/toddmotto/angularjs-styleguide


A section on testing would definitely be a great addition.


Very nice tutorial how about more on unit-testing


Yep, on it's way :)


Excellent overview of services vs factory vs provider. Most explanations of this just end up confusing the reader even more.


really like this tutorial. I was going to say it' be good to see more on nested scopes versus the controllerAs but you've also liked out to some great follow on content. Thanks!


If you mention that Angular was built by Google devs, then please mention that MVVM was invented by Microsoft devs (WPF):

http://en.wikipedia.org/wiki/Model_View_ViewModel


This guide covers filters better than anything I've ever seen.


Appreciate it, thanks for the awesome feedback! :)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: