Introduction to Angular JS

Hello! I hope you had a good day and an awesome week. 😊

In this post, I thought of giving you an idea what AngularJS is. Before getting to know what AngularJS is, you need to know what a single page application is.

 A single page application(SPA) is a web application or a web site which loads only a single web page and dynamically update that page as per user’s interaction. The goal of SPAs is to provide a user experience similar to that of a desktop application. SPAs use AJAX and HTML to create responsive web pages without constant page reloads. This means most of the work is done in the client side or front-end. Client having a dynamic communication with the server is a must in SPAs. Let’s see some features of SPAs,
  •           Appropriate content is dynamically added to the webpage.
  •           Use of AJAX for client server communication.
  •           Use of sockets for bidirectional communication.

As usual with the introduction of SPAs some complications occurred. One such concern is crawlers being unable to crawl through SPAs. A web crawler or more commonly known as a crawler (sometimes called as a spider) is a program which access websites and reads their information in order to create entries for a search engine index. As a solution, isomorphic approach is used. Isomorphic approach is using one set of codes, usually JavaScript or Node.js to render both front-end and back-end. Apart from this, there are other concerns which arose due to SPAs.

Now let’s see what AngularJS is.

AngularJS is an open source structural framework for web applications. Its initial release was on 2010 and is maintained by Google. It is based on JavaScript and lets you use HTML as template language. It is used to develop front-end and ease the pressure of developing single page applications. Listed below are some features of Angular JS.
  • Supports Model-View-Controller(MVC) and Model-View-Viewmodel(MVVM) architectures.
  •  Has a clear separation of views, controllers, models and componen
  • Facilitate two-way data binding from view to model and model to view. This one of the strongest features of Angular JS.
  • Automatic Dependency Injection. Dependency Injection is technique where one object supplies dependencies of another object. This is another strong feature of Angular JS.

Let’s go through some important components of Angular JS.


Module

 A module is a basic container for all Angular JS elements or we can say it as a collection of services, controllers, filters, directives and configuration information. A module will bundle Angular JS components together. These bundles can be used again and again. angular.module given the name of the module is used to configure a module.


Controller

A controller will initiate and keep the state as well as define behaviors, which basically means that it is a JavaScript object which contains attributes and methods. ng-controller can be used to define a controller as well as to bind it to a view. For the second purpose, we can a use router as well. Dependencies can be injected into a controller and one such dependency is $scope which is injected to enable the two-way binding between the view and the controller. $scope object has a life span which is only limited to its controller.


Service

A service is a JavaScript function which is responsible to perform only a specific task. Services are automatically injected by Angular JS runtime once it’s created, added into the module and referenced.

This was a tiny introduction and Angular JS is much more than this.


I wish you all an amazing week ahead! Adios 😊

Comments

Popular posts from this blog

Double Submit Cookies Pattern - Node.js

Setting up the Environment with Node.js

Synchronizer Token Pattern - Node.js