Thursday 2 March 2017

5 Pillars of AngularJS




We saw a Brief Introductionof AngularJS in our Previous Article. Here You go about the Main 5 Pillars of AngularJS. As we know that Starting an AngularJS Application is incredibly very Easy.

You can Implement Angularjs in your Application by just 2 stpes.

Step 1:

Just you need to include the Angularjs Library file in your HTML <head> Tag.
<script scr=”angulrjs.js”></script>

Step 2:

Initialize the Angularjs Module in you Application with root element of AngularJS.
<HTML ng-app>

That’s it, You have successfully implemented AngularJS in your Application.

To know more about the Trending Framework - AngularJS Visit us.

Here we go about the main 5 pillars of AngularJS. It will be helpful for further going. The names of 5 pillars are,

1.     Directives
2.     Controllers
3.     Scopes
4.     Services
5.     Dependency Injection

Lets see a glance about the above 5 pillars.

Check AngularJS lists of Other components also.

1. Directives

Directives are nothing but HTML Tags and attributes. AngularJS has plenty of inbuilt Directives and each directive has individual behaviors.
It extends existing HTML Tags with additional Attributes. AngularJS allows you to create your own Directives. It means you can create a directive in your name, like <your-name></your-name>
ng-bind, ng-controller, ng-model, etc., are the examples of Directives. Here the prefix ng represents “Angular”.
You can use ng-bind as data-ng-bind, ng_bind, ng:bind, x-ng-bind. But the good practice is ng-bind.

2. Controllers

In AngularJS Controllers are defined by JavaScript constructor function. It is used to controller Application data. The controller has very important property which is $scope . The controller should be light weight and shouldn’t add too much works here.

Mainly use controller for,
1.     Set up the initial state of $scope Object.
2.     Adding behavior (methods) to the $scope object.
All the controllers are attached with HTML  DOM via ng-controller directive.

For example,
<div ng-controller=”myCtrl”></div>

3.Scopes

$Scope is a regular JavaScript Object. It refers to the application data model. Scope is a property of controller. The scope may contain any kinday of data. All the inputs and responses are passed via the $scope. The Scope is available in both view and controller.

In view, the Scope attached with ng-bind directive or  via the expression {{}}

4.Services

In AngularJS Services are objects. The services are implemented in any controller via Dependency Injection. Once we injected the services into the controller, we can start to use. There are plenty of inbuilt services and also you can create custom services via the module. The services are start with “$”.


Examples of services are,
$http, $location, $timeout, $interval etc.,


5. Dependency Injection


Dependency Injection is software design pattern in which components are given dependencies to other components. Instead of rewrite the code from scratch, we can reuse via Dependency Injection. 

To know more about the other components in AngularJS, Click Here.