If you’ve ever sifted through job boards or even stackoverflow when it comes to Angular, you will see people use the terms “AngularJS” and “Angular” interchangeably. Or atleast that’s what it can sometimes appear to be. But AngularJS and Angular actually refer to two very different versions of Angular. While learning one basically gets you half way to learning the other, they are not necessarily interchangeable. So what’s the difference?
AngularJS Is Angular 1
Before we jump into the actual differences between AngularJS and Angular. The first thing you need to know is that the term “AngularJS” is typically used to refer to the very “first” version of Angular, Angular 1. When Angular 2 rolled out, it had tonnes of “breaking” changes from version 1. Infact it was a completely different architecture! Where Angular 1 used things like Controllers and used Scope/Rootscope, Angular 2 did away with these and made everything in your app a “component”.
Naturally some were adverse to such a hard shift and given that many applications were already written in version 1, people didn’t want to have to go through and update their entire application architecture so they stuck with it. Even as further versions of Angular rolled out (Angular 4, 5, 6 etc), Angular 1, now called AngularJS, received it’s own updates with things like performance boosts and security upgrades. For some, this meant AngularJS was still a very viable alternative to creating a Single Page App without having to re-learn a new framework.
Feature Comparison Between AngularJS And Angular
As mentioned above, Angular 2 introduced a completely new architecture of “everything” being components. Because of this you could almost say it’s a different JS framework, but I’ll try and list out a couple of important differences between the two versions.
- Angular uses Typescript (as default but you can use Javascript also) while AngularJS uses plain Javascript.
- Angular makes everything a “component” and you use these as blocks to create your app. While AngularJS is primarily MVC (Model-View-Controller) based.
- Angular makes uses of it’s own CLI to create components, run tests, serve the app etc while AngularJS does not have a CLI at all.
- Angular has it’s own inbuilt packaging system using Webpack while AngularJS requires you to roll your own (Often Gulp, but you can also use Grunt or Webpack)
- AngularJS requires different attributes to say whether you want two way or one way binding (e.g. ngModel vs ng-bind) whereas Angular just uses [] or ()
- Angular has a component based CSS encapsulation concept, AngularJS does not
- Angular supports server side rendering, AngularJS does not
This is by no means an exhaustive list. Realistically, I could list out many “annoying” gotchas with AngularJS that were fixed in Angular 2+. For example data binding in Directives is a right pain to learn in AngularJS and is by no means intuitive, you need to learn crazy text symbols to work out how multi directional binding works :
{
scope: {
text: "@myText",
twoWayBind: "=myTwoWayBind",
oneWayBind: "&myOneWayBind"
}
}
Whereas in Angular this is just so much more intuitive.
Should You Start A New Project On AngularJS Or Angular?
Angular. 100% Angular.
On July 1st 2018, AngularJS entered into lifetime support mode. This means it’s not actively being worked on (feature wise), and new releases will only contain security fixes or critical bugs caused by a new browser version. This is expected to last until June 2021 at which point support will end. So at best the AngularJS you have right now will continue to be the same in the future, and at worst from mid 2021 onwards your framework will no longer be “supported”.
Angular just fixes so many issues with AngularJS with a very small learning curve. If you know AngularJS already, then getting started on Angular won’t be a hassle at all. If you are starting fresh and thinking of building your first SPA, there is no reason to pick a framework with notable gotchas that will run out of support in a years time.
💬 Leave a comment