While we embrace the culture of learning and sharing within the organization, I was eager to spread it to a larger forefront with help of communities and informal gatherings. It always feels good to connect with like-minded people, exchange your ideas and collaboratively grow as a community.
Meet Up on Introduction to AngularJS was born out of such an idea. This Meet Up is an initiative to help all tech enthusiasts in the town to get hands-on the top-notch technologies and grow in the rapidly evolving world of mobility. Let me share a few important discussions and takeaways here.
The Agenda of the Meet Up was
- Introduction of AngularJS
- Why it is important in a glut of all other technologies
- Who should use AngularJS
- What are the benefits
What is AngularJS?
AngularJS is built around the belief that declarative programming should be used for building user interfaces and wiring software components, while imperative programming is excellent for expressing business logic.
Below mentioned are a few highlights of AngularJS
- HTML enhanced for web apps.
- MVW Architecture(Model View Whatever)
- The framework supporting Web Components and MDV(Model Driven Views)
The framework adapts and extends traditional HTML to better serve dynamic content through two-way data-binding that allows the automatic synchronization of models and views. As a result, AngularJS de-emphasizes DOM manipulation and improves testability & performance.
Angular follows the MVW pattern of software engineering and encourages loose coupling between presentation, data, and logic components. Using dependency injection, Angular brings traditionally server-side services, such as view-dependent controllers, to client-side web applications. Consequently, much of the burden on the backend is reduced, leading to much lighter web applications.
MVW Architecture (Model View Whatever)
A basic concept of MVW is that all definitions are associated with a named Module. Modules can then be aggregated to form complete web applications. Modules can depend on one another, so that including a single Module in your Web Application may bring along additional functionality on which that Module depends.
I hope the kick-off is good enough to arouse interest in the history behind AngularJS!
- AngularJS was originally developed in 2009 by Miško Hevery and Adam Abrons at Brat Tech LLC as the software behind an online JSON storage service.
- Their software has been priced by the megabyte, for easy-to-make applications for the enterprise. This venture was located at the web domain “GetAngular.com”.
- Before the two decided to abandon the business idea and release Angular as an open-source library, Abrons left the project, but Hevery, who works at Google, continues to develop and maintain the library with fellow Google employees Igor Minár and Volta Jína.
What should be the design goals of AngularJS?
Decouple DOM manipulation from application logic. This improves the testability of the code.
- Application testing holds equal importance as application writing. The testing difficulty is dramatically affected by the way the code is structured.
- Decouple the client side of an application from the server-side. This allows development work to progress in parallel and allows for reuse of both sides.
- Guide developers through the entire journey of building an application: from designing the UI to writing the business logic and testing.
Features of Angular JS
Data-binding is an automatic way of updating the view whenever the model changes, as well as updating the model whenever the view changes. This is awesome because it eliminates DOM manipulation from the list of things you have to worry about.
Controllers are the behavior behind the DOM elements. AngularJS lets you express the behavior in a clean readable form without the usual boilerplate of updating the DOM, registering callbacks, or watching model changes.
A deep link reflects where the user is in the app, this is useful so users can bookmark and email links to locations within apps. Round trip apps get this automatically, but AJAX apps by their nature do not. AngularJS combines the benefits of deep link with desktop app-like behavior.
AngularJS provides built-in services on top of XHR as well as various other back-ends using third-party libraries. Promises further simplify your code by handling the asynchronous return of data.
Directives is a unique and powerful feature available only in Angular. Directives let you invent new HTML syntax, specific to your application.
We use directives to create reusable components. A component allows you to hide complex DOM structure, CSS, and behavior. This lets you focus either on what the application does or how the application looks separately.
An important part of serious apps is localization. Angular’s locale-aware filters and stemming directives give you building blocks to make your application available in all locales.
AngularJS works great with other technologies. Add as much as or as little of Angular JS to an existing page as you like. Many other frameworks require full commitment. This page has multiple AngularS applications embedded in it. Because AngularJS has no global state multiple apps can run on a single page without the use of iframes, we encourage you to view-source and look around.
The dependency injection in AngularJS allows you to declaratively describe how your application is wired. This means that your application needs no primary method which is usually an unmanageable mess. Dependency injection is also a core to AngularJS. This means that any component which does not fit your needs can easily be replaced.
AngularJS was designed from the ground up to be testable. It encourages behavior-view separation, comes pre-bundled with mocks, and takes full advantage of dependency injection. It also comes with an end-to-end scenario runner which eliminates test flakiness by understanding the inner workings of AngularJS.
Now let’s jump on to understand: Why AngularJS?
Angular implements MVC by asking you to divide your app into components and then Angular manages the rest for you along with the server as the pipeline that connects them. As compared to other frameworks which ask you to divide the app into components and at the same time require you to write code to string them up together again. As Angular acts as the mediator, developers also won’t feel tempted to write shortcuts between components that break abstractions just to make them fit easier.
Extensible UI (declarative user interface)
POJO type Data Models
AngularJS bounds all the properties of the data model to the associated view and quietly watches the change to these properties and updates the view automatically when it senses any change in the property. All the data in scope are feed by controllers according to business logic need.
Directives & Reusable components
Directives are the features provided by Angular to create Reusable components and bring additional functionality to HTML. Once a directive has been created you need to just use it as a regular HTML tag and provide appropriate attributes to it, without worrying about DOM manipulation to render them.
Directives are designed to be standalone reusable elements separate from your app. In fact, if a particular element becomes adopted by the HTML5 standard, it should be as simple as removing your custom directive, and your app should behave exactly the same without needing to change your app.
Filters providing flexibility
Filters are standalone functions separate from the application like directives but the main functionality of filters is the transformation of data from one format to another format. There are various types of filters that allow you to perform simple tasks like formatting-decimal place, formatting dates, sorting the array, reversing the order of the array, etc.
Filter just filters the data using the transformation function before it is rendered in a view.
Basically, when it comes to cross-browser support, the main problem comes with IE. While AngularJS works well with all the browsers, there are some criteria and steps listed by AngularJS to take into consideration for IE.
Till now we talked about various benefits, and let me put them all together here:
- We don’t have to write our own MVC Pipeline
- Data models are simple
- Data binding means you don’t have to worry about DOM manipulation.
- Directives are separate from the main application, which allows parallel development and gets integrated with minimal issues and code
- Filters allow you to transform data from one format to another without changing anything in the controller and using it directly in view.
In-Place DOM Manipulation
In general terms, view manipulates the DOM to present the data and to add behavior. All the DOM manipulation in AngularJS occurs in directives rather than in view. AngularJS interprets view as a separate HTML page with placeholders for data, this makes the UI designers work well in the application.
As DOM manipulation is taken care of by AngularJS, UI Designer can focus on the view without worrying about DOM manipulation logic being written at the backend.
It becomes great fun in developing web applications by making app purely about presenting data into views, and not having to worry about DOM manipulation.
In-Place Service Providers (SP)
Service Provider is the functionality provided by AngularJS which does not get involved in the main Web App, it just provides an API to expose the functionality you need to expose to the main Web App. The primary use of SP is to
- Create a resource-sharing service that allows data sharing between multiple controllers.
- To expose functions that interact with the server to push and pull the data and provide offline data.
The primary task of the Controller in AngularJS is to focus on the View and Scope to which it is assigned. Controllers in AngularJS is a simple POJO functional that manipulates the scope, performs validation, pre-fills form using data from the server. Hence controller uses the SP to get the data without worrying about backend logic or stuff involved.
These is the Services that help AngularJS to make the controller lightweight and perform all the heavy Data manipulation in Services.
Good Unit Testing Support
The whole of AngularJS is linked together by Dependency Injection (DI). It’s what it uses to manage your controllers and scopes. Because all your controllers depend on DI to pass its information, AngularJS’s unit tests are able to usurp DI to perform unit testing by injecting mock data into your controller and measuring the output and behavior. In fact, AngularJS already has a mock HTTP provider to inject fake server responses into controllers.
This beats the more traditional way of testing web apps by creating individual test pages that invoke one component and then interacting with it to see if it works.
Supports better routing
When you want to develop a web app using JS and HTML, the main problem lies in processing URLs and passing parameters to URLs as we pass to any backend in form of POST data or Query Params. AngularJS solves this problem by providing good support for Deep Linking of routes (URL) to Controllers and Views. This will make the task of developers very easy to get Query params in the Controller. It provides support for routes similar to that provided in RoR, but in a slightly different manner by binding URL to View and controller.
Post your questions or doubts as blog comments below. I would love to help initiate an engaging conversation. Participate in our next meet-up on “Building Directives” on 31st October and keep watching this space for its informative blog post.
Receive articles like this in your mailbox
Sign up to get weekly insights & inspiration in your inbox.
2500 people are reading this blog every week
CompanyApril 08, 2021
Rapidops, Inc. is one of the fastest-growing digital immersion companies in the world. We support our customer’s growth...
CompanyJanuary 11, 2021
In December 2020, Charlotte Business Journal ranked Rapidops Inc. number 5 in its Fast 50: Charlotte’s fastest-growing ...
CompanyAugust 14, 2020
For the 2nd Time, Rapidops Appears on the Inc. 5000, Ranking No. 1560 With Three-Year Revenue Growth of 279.72%. ...