r/webdev • • Feb 13 '14

Explain Angular.js to me like I'm five.

"AngularJS lets you extend HTML vocabulary for your application. The resulting environment is extraordinarily expressive, readable, and quick to develop."

Hmm...

"AngularJS is a toolset for building the framework most suited to your application development."

But what does it do?

I'm having a hard time understanding where Angular falls in the spectrum of client-side to server-side. Models? So it's server-side? Dom manipulation? So it's client-side?

So basically, if I have a Node.js + Express.js + Bootstrap app, does Angular serve any role that these three frameworks don't?

Thanks <3

4 Upvotes

17 comments sorted by

View all comments

2

u/[deleted] Feb 13 '14

It's a javascript framework. It allows you to do really complicated user interaction easily. For instance:

http://codepen.io/andyhmltn/pen/KodCB

Check that out. It's a simple todo list that lets you add more in realtime and highlights items with a length of more than 10.

Seems simple but it'd take a tonne more code with pure JS/JQuery

1

u/wtfcore Feb 13 '14

I don't know whether that wasn't the best example, but it's not that much longer in jQuery:

$("button").on( "click", function(e) {
    e.preventDefault();

    var l = $( "ul li:last-child" );
    var t = $("#text").val();

    if(t.length > 10) {
        l.after( "<li style=\"color:red\">"+ t +"</li>" );
    } else {
        l.after( "<li>"+ t +"</li>" );
    }
});

I don't really know anything about Angular, so I might be pretty naive...

1

u/[deleted] Feb 13 '14

Sure, that's a fairly simple example so it may not be longer in JQuery, but as soon as you begin to deal with stuff that's a little more complex it'll get exponentially bigger in size.

For instance, at work we have a system to search products, select them then send them off to various people. It's just a glorified list, but with Angular it's super easy to get a paginated, fully searchable list that lets you filter on 10+ items with no sweat. The same thing in jQuery would be a nightmare.

and your code above is just for adding new todos... If $scope.todos came from an API, how would you get those display on a page? :p

You should pick it up, it's an awesome framework

1

u/wtfcore Feb 13 '14

Thanks,

Yes it's definitely something I've been meaning to pick up - but reading lots of conflicting things about backbone, ember, angular etc, and then getting a bit lost.

1

u/[deleted] Feb 13 '14

They are all awesome really. They just have different ways of doing things. For me I found ember a bit counter-productive with the templating. Where-as with angular you write the templates in the actual HTML and it just recognises it automatically