Profile Picture

Sirwan Afifi

Stories from a web developer.

© 2015. Sirwan Afifi All rights reserved.

Why AngularJS?

I wanted to share a few thoughts about AngularJS

Introduction

AngularJS is a MV* framework for writing manageable, clean, full-featured applications in the browser with JavaScript , It’s also incredibly easy to learn for those who already have HTML and JavaScript experience. Angular’s goal was to create a way for designers to be able to do HTML design using components. One thing that I like about Angular is that, it’s an opinionated MV* framework, It means that it tells you what are the certain ways of doing things, Some people might argue that it’s somehow a limitation for a framework such as Angular because it solves fewer problems, but I think at least it assures to not having spaghetti code.

How I got into AngularJS

I have been sitting on the fence for far too long to chose a great JavaScript framework. Finally a couple of years ago I decided to use AngularJS and it caught my attention. It actually made me cursious to learn more about it. I started to use AngularJS for some parts of my application. At the time Angular team were working on the next version of the framework So I stopped using it because I heard that the next version is a different framework. Now I have come to conclusion that it’s better to stick with Angular 1.x, then I can switch to Angular 2 in a right time.

AngularJS Benefites

Angular has lots of great features from testability and two-way binding, to more vague concepts. For me the best thing about Angular is that it has a flat learning curve So you can get the most of it. All being said here are the some of my favorite features and benefits of Angular:

For example take a look this piece of code written in raw JavaScript:

document.getElementById('btn')
.addEventListener('click', function(el) {
    alert('clicked!');
});

Whereas with Angular you can simple achieve same goal this way:

<button id="btn" ng-click="handleClick()">Click Me</button>

$scope.handleClick = function() {
    console.log('clicked!');
}

As you can see the Angular code is less complex.

AngularJS gotchas

Although Angular is a great framework but it has some problems that you can run into trouble with it. Here are some of them:

Conclusion

Even though Angular 2 is coming, But Angular 1 is still a thing and I think Angular 1 will be supported for a long time to come.