top | item 6328685

AngularJS Tutorial: Learn to Build Modern Web Apps

326 points| mfrisbie | 12 years ago |thinkster.io

91 comments

order
[+] jmduke|12 years ago|reply
I'm not sure if I'm more excited or creeped out. Yesterday, I decided I wanted to learn Angular and I figured making a fantasy football clone would be a fun, interesting way to do it -- something I'm vaguely passionate and vaguely knowledgeable about, something that isn't a Twitter clone, lots of numbers, something I can show to a few friends without having their eyes glaze over.

Then this came out. Super excited for the weekend so I can dive on through. Thanks, Matt -- but stop reading my mind.

(n.b.: I'd be more than willing to pay sticker price if I could get a physical copy instead. I know it's lame, and slightly more effort, but I don't have a monitor setup at the moment so I'd rather leaf through a book than scroll through an alt-tabbed .pdf.)

[+] aray|12 years ago|reply
Ditto for paying for a print copy. Some tech books I'd rather read outside in the sun; it forces me to actively try to internalize more instead of hopping to/from the console every minute.

Maybe http://lulu.com ?

[+] victoro|12 years ago|reply
Agreed with the 'reading my mind part'. Though it is high time for fantasy season so its probably at the front of everyone's mind right now. Anyway, very excited to get into this.
[+] ericmsimons|12 years ago|reply
Hey all - we'd love to hear any questions, criticism, or ideas you have.

Also, we have a pdf version of the ebook available for $25 on the site, but we'd like to give all of you on HN a 20% discount. You can go to this URL to get the cheaper price - http://gum.co/SUry/awesomehners

Thanks for all of your support!

[+] Omnipresent|12 years ago|reply
It would be great to see a demo of the app being built. Either a couple of minutes of video or an actual link!
[+] JelteF|12 years ago|reply
Like I said in another comment, the git clone command should be fixed to use https instead of ssh. That way it would be able for users that have no access to the repository (almost anyone) to clane it without any problems.

  git clone https://github.com/msfrisbie/mean-stripdown.git
[+] matt_|12 years ago|reply
Edit: Nevermind.
[+] jjsz|12 years ago|reply
There's also: yearofmoo [0], the AngularJSLearning Index [1], David Mosher [2], tutorialzine [3], and the ng-newsletter. [4] I would like to see the Integration With Other Languages/Frameworks section expanded (D3, PouchDB, etc). Are you guys planning on expanding on that?

[0] http://www.yearofmoo.com/

[1]https://github.com/jmcunningham/AngularJS-Learning,

[2] http://www.youtube.com/user/vidjadavemo/videos

[3] http://tutorialzine.com/2013/08/learn-angularjs-5-examples/

[4] http://www.ng-newsletter.com/posts/beginner2expert-how_to_st...

[+] mfrisbie|12 years ago|reply
I get a lot of requests to expand the tutorial with other frameworks, as you mentioned. Ultimately, the tutorial itself will be structured in a way that allows for the best presentation of concentrated learning. However, this doesn't mean that we won't be releasing other content covering integration with other frameworks.
[+] jjsz|12 years ago|reply
I'll take that as a no since you haven't responded.
[+] davidwparker|12 years ago|reply
Working with a large Angular app, I've found it much nicer to split away from the "Rails"-style convention of grouping by type (controllers, models, etc) and instead grouping by modules. This plays especially well with Angular where you can group everything within a module together and include a single module which ties all the dependencies together.

Curious if others do something similar and group code together by modules or does everyone group by type?

[+] Rodeoclash|12 years ago|reply
Can you give an example of how you've organised the modules? Like one per model (a products module) or by section of the site?
[+] p3rs3us|12 years ago|reply
I recently spent days writing AngularJS app and I came to same conclusion that I should have split the app into modules. Even though the style of grouping together Controllers and Services works well, it still won't be easy to maintain when the size of app grows big.
[+] joevandyk|12 years ago|reply
I like grouping by functionality. All the account-related code in one directory, all the order-related code in another, etc.

Bugs me to have the order logic spread out in the views, models, controllers, hepers, libs, etc folders.

[+] babby|12 years ago|reply
I'm always excited to structure my projects in a different more effective way - well, it's more of a struggle - anyway, this sounds interesting. Can someone elaborate on the file structure and structure of files and the way they connect?

I'm rolling with a MVP structure that frankly is becoming cumbersome with my current project's size.

[+] mac1175|12 years ago|reply
I do it the way you just mentioned. I create specific modules and have them inject their dependencies. Each modules I create has its one or more models within its domain. I was going to go the repository route (one module per type) but it seemed overkill.
[+] t0mas88|12 years ago|reply
For front-end such as Angular I always group in modules, usually nested modules for larger apps. For back-end systems sometimes type makes more sense, especially when the app grows quite big and uses a layered architecture.
[+] ganarajpr|12 years ago|reply
I do the same as you. Group by Module - which in my humble opinion is the real intention of the modules.

Oh between I do group by Type inside of a module.

[+] BlackJack|12 years ago|reply
This article/book was marked as [dead] for a while, then got unmarked. How exactly does that happen?
[+] otikik|12 years ago|reply
I'm still not convinced about Angular's Dependency Injection thing. The problems it allegedly solves don't clearly outweigh the ones it certainly creates.

It claims to provide concern isolation, which facilitates testing and cleanliness. I don't think it helps that much.

But it has a middle-stage learning curve, more callbacks than I'd like, and implicitness of dependencies. For example, i.e. you need to know what $scope-like params are "supposed to contain" on every function that uses them.

Also, I find the naming spotty: "directive", "module", "injector", "compile" etc. lack specificity. They are not as bad as "Manager", "Data", "Info" and "Object", but they are not good.

[+] Nitramp|12 years ago|reply

    For example, i.e. you need to know what $scope-like params are "supposed to contain" on every function that uses them.
You should never write code that communicates through $scope objects and expects certain values to be set. The only exception to this is the relationship between views and their respective controllers.

Outside of the controller-view relationship, nothing in AngularJS requires passing data in $scope objects, and you definitely shouldn't.

Why do you think dependency injection doesn't help exactly? I personally don't know of any other pattern to effectively test/mock things like HTTP interactions. It's also a pattern that's used by many, many other languages and frameworks - what's the alternative you're thinking about?

[+] weavie|12 years ago|reply
The tutorial recommends starting your server using `node server`.

With MEAN a Grunt file is provided. Running the server with `grunt` will make grunt run the server and then watch the directory for changes - restarting the server and refreshing the page as necessary.

Much easier.

[+] nekopa|12 years ago|reply
I tried to use grunt as you say with the tutorial, but it didn't work. They say they are using a stripped down version of MEAN, so maybe they took that out? Do you know a good tutorial on adding it back in, as I like the sound of the functionality you're talking about...
[+] Geee|12 years ago|reply
Is there a demo of the finished app somewhere? I don't want to read or buy the tutorial before I see how good the actual result is.
[+] mfrisbie|12 years ago|reply
The tutorial is still having the finishing touches put on it, once it's completed there will be a demo available.
[+] mmanfrin|12 years ago|reply
Looks great -- and I really appreciate that the demo site is not a cookie-cutter twitter clone like half the tutorials out there.
[+] mfrisbie|12 years ago|reply
Thanks! I can't stand twitter clones either, I figured it was better to have people learn to build something out of their comfort zone.
[+] metastew|12 years ago|reply
One advantage of the MEAN stack is that you only need to know javascript to start developing on it, which saves time and brainpower to get started.

That being said, I'm curious if there are other advantages to learn the MEAN stack?

[+] wavesounds|12 years ago|reply
Javascript is a harder language then most web development languages when you really get into it (OOP, inheritance, scope, first class functions, callbacks, closures, compile time errors). If you go into it thinking your going to save brain power you may be in for a rude awakening.

The advantage is you can do real time async stuff a lot better then with other frameworks.

[+] weavie|12 years ago|reply
I've just kicked off my latest project using the MEAN stack.

The main advantage for using the stack has been a huge time saving in getting the project set up. NodeJS and express is hugely flexible about how you structure your source, which can also be a downfall in the additional mental load of deciding where stuff should go. MEAN does this for you.

The disadvantage has been where I want to do things differently from how MEAN is set up. For example, MEAN uses Bootstrap v2, I wanted Bootstrap v3. It was a slight faff updating it. It would probably be harder if you eg. wanted to use MySQL instead of MongoDB.

There is still a lot that you need to learn before you will get an app fully up and running, but with MEAN you can get cracking on stuff before you know it all. I don't know anything about Grunt yet, but can still use the Grunt file provided to run the server.

Well worth using in my opinion.

[+] ericmsimons|12 years ago|reply
It's super simple to set up. We're actually thinking of doing a Firebase version of our tutorial, as there would be no local set up (other than hosting the static files).
[+] thomc|12 years ago|reply
Looks good, and useful to me, nice work.

Will you be covering security in any detail? Most people seem to miss this and I'm discouraged to see when I download the MEAN project this is based on it has serious security flaws.

For example, if you view the articles list at /#!/articles and make a note of any article ID, then visit /article/<article_id> it will return the article author's hashed password, salt and email address in addition to the article content. This also works while logged out. Kinda scary if people are using this as a template for their own apps.

[+] bemurphy|12 years ago|reply
Yeah that freaked me out too. I'm not super familiar with mongoose either so at the time I couldn't figure out how to leave them out of serialization always. I could do it for one-off calls but there should be a way to generally whitelist I'd think.
[+] mfrisbie|12 years ago|reply
That was one of the first things I noticed when examining the MEAN stack. The final version of the tutorial will take care of this flaw.
[+] elbac|12 years ago|reply
The best place I have found to learn about Angular is http://egghead.io . The videos are really clear and concise.

Many of the more confusing Angular fundamentals that many tutorials like these don't stress egghead.io has short 2 to 3 minute videos explaining in very clear terms.

PS. I know I sound like a shill, but I have nothing do with egghead.io other then I've found them immensely useful.

[+] pmtarantino|12 years ago|reply
I really like this is not an ebook per se, but an interactive tutorial. The checkbox to save your progress are really great :) Congratulations!
[+] WalterSear|12 years ago|reply
Angular: ad hoc crowd sourced documentation at it's finest.
[+] beefsack|12 years ago|reply
Kind of surprised how in depth the tutorial goes, but only manages to mention the word "test" once and doesn't cover the fantastic testing back end included with the AngularJS seed (https://github.com/angular/angular-seed).

Unless the person learning AngularJS has never done any automated testing before, I can't see any reason why not to be using tests as a tool to further your own learning. I learned Go last year relying heavily on tests, first specifying what I wanted to achieve in a high level test, then learning as I figured out how to make the test pass.

[+] mfrisbie|12 years ago|reply
Believe me, a big testing section is on the way.
[+] marknutter|12 years ago|reply
Nice tutorial. One critique is the use of the "ng" prefix for your app's modules, which I believe is discouraged by the angular core developers since it's supposed to denote core angular functionality.
[+] aidos|12 years ago|reply
Looks like a solid walk through of building an angular app.

OT but the fantasy football twist is great. I only just started playing this year so I've been learning a lot. We're playing the uk version but I guess it's much the same. I've found it interesting how much strategy there is and how much data I can analyse.

We have a startup in the construction industry so wanted to use it as a tool for keeping a sort of weekly offline / banter conversation going on with clients. Turns out that I actually enjoy too!

[+] martindale|12 years ago|reply
Nice work! I love how all the individual components are one big scrollspy. We (Coursefork) had a call with Eric yesterday to figure out how to make this kind of material "forkable", but something we didn't talk about was this idea of charging for the "source source code". What exactly does that mean?
[+] arms|12 years ago|reply
This looks very interesting, thanks for sharing. I especially like that you decided to go with a fantasy football app - can't say I've seen many tutorials do that ;) And last but not least, I like that you chose the MEAN stack, for no reason other than I am unfamiliar with it and have been meaning to look into it.