What is AngularJS?
AngularJS is a client side JavaScript MVC framework to develop a dynamic web application. AngularJS was originally started as a project in Google but now, it is open source framework.
AngularJS is entirely based on HTML and JavaScript, so there is no need to learn another syntax or language.
AngularJS is also called just "Angular".
AngularJS changes static HTML to dynamic HTML. It extends the ability of HTML by adding built-in attributes and components and also provides an ability to create custom attributes using simple JavaScript.
AngularJS website - https://angularjs.org
AngularJS Official Website
As you can see in the above angularjs.org website, you can download AngularJS 1 library by clicking on the Download AngularJS 1 link. AngularJS 2 is in the beta version as of this writing. This tutorials is using AngularJS 1.
Angular is an open source framework. Click on View on GitHub link to see the source code.
AngularJS Example:
The following is a simple AngularJS example that changes a label to whatever you type in the textbox.
AngularJS Example:

<!DOCTYPEhtml>

<html>
<head>
<scriptsrc="~/Scripts/angular.js"></script>
</head>
<bodyng-app>
    Enter Your Name: <inputtype="text"ng-model="name"/><br/>
    Hello <labelng-bind="name"></label>
</body>
</html>

The above example is plain HTML code with couple of AngularJS directives (attributes) such as ng-app, ng-model, and ng-bind.
The same task can be accomplished using jQuery with more lines of code, as shown below.
jQuery Example:

<!DOCTYPEhtml>

<html>
<head>
<scriptsrc="~/Scripts/jquery-1.10.2.min.js"></script>
</head>
<body>
    Enter Your Name: <inputtype="text"id="txtName" /><br />
    Hello <labelid="lblName"></label>

<script>
        $(document).ready(function< () {
            $('#txtName').keyup(function () {
                $('#lblName').text($('#txtName').val());
            });
        });
</script>
</body>
</html>

Thus, AngularJS includes built-in attributes using which we can increase the productivity.
Advantages of AngularJS:
  1. Open source JavaScript MVC framework.
  2. Supported by Google
  3. No need to learn another scripting language. It's just pure JavaScript and HTML.
  4. Supports separation of concerns by using MVC design pattern.
  5. Built-in attributes (directives) makes HTML dynamic.
  6. Easy to extend and customize.
  7. Supports Single Page Application.
  8. Uses Dependency Injection.
  9. Easy to Unit test.
  10. REST friendly.
Let's setup AngularJS development environment in the next section.
Core Features
Following are most important core features of AngularJS −
·        Data-binding − It is the automatic synchronization of data between model and view components.
·        Scope − These are objects that refer to the model. They act as a glue between controller and view.
·        Controller − These are JavaScript functions that are bound to a particular scope.
·        Services − AngularJS come with several built-in services for example $https: to make aXMLHttpRequests. These are singleton objects which are instantiated only once in app.
·        Filters − These select a subset of items from an array and returns a new array.
·        Directives − Directives are markers on DOM elements (such as elements, attributes, css, and more). These can be used to create custom HTML tags that serve as new, custom widgets. AngularJS has built-in directives (ngBind, ngModel...)
·        Templates − These are the rendered view with information from the controller and model. These can be a single file (like index.html) or multiple views in one page using "partials".
·        Routing − It is concept of switching views.
·        Model View Whatever − MVC is a design pattern for dividing an application into different parts (called Model, View and Controller), each with distinct responsibilities. AngularJS does not implement MVC in the traditional sense, but rather something closer to MVVM (Model-View-ViewModel). The Angular JS team refers it humorously as Model View Whatever.
·        Deep Linking − Deep linking allows you to encode the state of application in the URL so that it can be bookmarked. The application can then be restored from the URL to the same state.
·        Dependency Injection − AngularJS has a built-in dependency injection subsystem that helps the developer by making the application easier to develop, understand, and test.
Concepts
Following diagram depicts some important parts of AngularJS which we will discuss in detail in the subsequent chapters.

Disadvantages of AngularJS
Though AngularJS comes with lots of plus points but same time we should consider the following points −
·        Not Secure − Being JavaScript only framework, application written in AngularJS are not safe. Server side authentication and authorization is must to keep an application secure.
·        Not degradable − If your application user disables JavaScript then user will just see the basic page and nothing more.
The AngularJS Components
The AngularJS framework can be divided into following three major parts −
·        ng-app − This directive defines and links an AngularJS application to HTML.
·        ng-model − This directive binds the values of AngularJS application data to HTML input controls.
·        ng-bind − This directive binds the AngularJS Application data to HTML tags.

Post a Comment

Powered by Blogger.