Having studied computer science in college, I had strong fundamentals in backend systems, algorithms and debugging, so the change to web development was disappointing, to say the least. No more IDEs and being able to comb through your code as I had been taught; instead it is more of an experiment where you change some code, pray a little bit and hope everything looks decent. Don’t get me wrong– there are methods/tools that you can use for debugging in web development– but in comparison to backend programming, it is messier. A lot of hit-and-miss– not much algorithmic problem solving.
And after a year of that, I said: I am done with that. I have used a variety of frameworks and technologies to change my development approach and AngularJS is one that I recommend. Here are the top 5 reasons why:
- Hiding/Showing Elements is a Breeze: this task is one that web developers constantly deal with for many reasons. We can use ng-show, an attribute in an HTML element, that holds a boolean expression (an expression that evaluates to true or false); the element is shown if the expression evaluates to true (or hidden if false), and will be updated automatically! Continuing from our previous example of the model for the data-import wizard, we could have a series of steps in the wizard (e.g. first, type name; second, choose the data source; third, select where to save), where the elements shown in the first step only show if a certain value is true, and the same holds for the other steps. We could simply have our “Next” button in the wizard change this value in the model, and the ng-show attribute will automatically hide the the current step and go to the next.
- Reusability with Directives: one of the key aspects of AngularJS is its ability to create “directives.” This allows you to create a function or action that will be used throughout the web application without having to worry about the specific case or HTML elements. For example, in our data-import wizard, we could create a directive that sends a file to our server at a specified location. Our directive lets you set the file and the save location, so it is generalized, but the code that sends the XHR request will remain the same. Directives also allow these functions to be called asynchronously, so that your data model (the controller) can move on and smoothly run the application without waiting.
These are just 5 great reasons to use AngularJS, but there are tons more that make developing web applications easier. There is always a learning curve when it comes to learning new technologies, but I can certainly vouch that it is worth the time for AngularJS.