Before reading this article, I highly recommend reading my previous part:
Introduction
In the previous part of Hands on Agular Js-I we discussed the basics and the architecture of AngularJS and few directives. Here in this part we will check out the other important directives and how Angular interacts with Controller and how model is being done on the go. The directives we will discuss in this part of series are very important in order to start and feel the magic of Angular. Here, actually we go into the depth and controls of Angular. Let's have a look.
Angular directives
Here we start with the other important directives that would come in handy while working on the Angular.
ng-module
Angular modules are the most important directives, they define an angular application. They are the parent set for the other directives or functions of the application, like controllers. Controllers are always contained within the modules, along with other dependencies. This is the modular approach in Angular. Creating modules for separate sections segregates it and creates partition/module wise applications. The modules are defined syntactically as below:
- var app = angular.module("app-Services", []);
ng-controller
This is another set of directives that defines the controller of the application, which controls the data of the application. They are simple objects defined under the scope of the module. There can be any number of controllers for a specific module. Controllers are defined syntactically as:
- var app = angular.module('app-Services', []);
- app.controller('myFirstController', function ($scope)
- {
- $scope.firstName = "Suraj";
- $scope.lastName = "Sahoo";
- });
- {{ctrlFirst.firstName}} {{ctrlFirst.lastName}}
- var app = angular.module('app-Services', []);
- app.controller('myFirstController', myFirstController);
- function myFirstController($http, $scope)
- {
- $scope.firstProperty = 'XYZ';
- $http.get('your url').then(function ()
- {
- //do whatever.. }).catch(function (){ //do whatever.. }).finally(function (){ //do whatever.. });
- }
- });
- $http.get: To retrieve information from server for a url requested by the user
- $http.head: Transfers only the header and the status line only, but is same as GET
- $http.post: As self explanatory it is, used to send the information entered by user to the server.
- $http.put: This is same as the POST but is used to create the current representation of the target resource or overwrite it for the same URL
- $http.delete: This ensures that the current resource for the requested URL is deleted by the server.
Filters in Angular JS
These are very interesting features provided by Angular, which can be used frequently and with ease. We will discuss below the pre-defined filters provided by the framework. We will see the use syntactically after the line-by-line explanation.
- currency:- This is used as the name suggests, to convert a simple number into the format of a currency.
- date:- This is used to format dates in different formats.
- filter:- An interesting filter which actually filters few data from a set of result set data.
- json:- Format an normal object into JSON format.
- limitTo:- Limits an set of array to specified number of elements or objects.
- lowercase:- Converts/formats an string to lower case character.
- number:- Format a simple number into a string.
- orderby:- Orders an array based on an expression.
- uppercase:- Format the string into a upper case character.
- var app = angular.module('app-Services', []);
- app.controller('myFirstController', function ($scope)
- {
- $scope.firstName = "Suraj";
- $scope.lastName = "Sahoo";
- });
- {
- {
- ctrlFirst.firstName | uppercase
- }
- }
- {
- {
- ctrlFirst.lastName\ lowercase
- }
- } //Displays firstName is UPPERCASE and lastName in lowercase
- {
- {
- x.name + ', ' + x.age
- }
- }
- {
- {
- price | currency
- }
- }
- {
- {
- name
- }
- } //Filters names based on names containing 'S'
{{ name }}
What the above snippet does is it loops through the names, and based on the entry in the textbox or the user input - supposethe user enters 'S' - then the data listed are filtered on the object with the names that starts With 'S'. Thus, we see how these filters become handy and really useful.
Conclusion
Thus, here in this part we discuss most of the great features of Angular and see a few snippets to be used in progress. As I said earlier, in the succeeding modules we will gradually come across more interesting features and overall use of Angular.
What's Next?
We will next come across how to build applications using Asp.NET MVC, EF Code First, Angular JS. That I assureyou will be interesting.
References
W3 schools docs.angularjs.org.

Rajeev PunhaniPosted Mar 28, 2016, 2:06 AM
Thanks for sharing.
Former memberPosted Feb 6, 2016, 12:21 AM
You explained basic stuffs of AngularJs. AngularJs architecture includes below points:1) Startup - what is the flow of angularjs with browser, static Dom, dynamic dom, content loaded event, $compile, $rootScope, 2) Module and Injector 3) Module Load cycle 4) Runtime 5) Scope's $digest() method.
Former memberPosted Feb 6, 2016, 12:13 AM
You explained basic stuffs of AngularJs. AngularJs architecture includes below points:1) Startup - what is the flow of angularjs with browser, static Dom, dynamic dom, content loaded event, $compile, $rootScope, 2) Module and Injector 3) Module Load cycle 4) Runtime 5) Scope's $digest() method.
Santhakumar MunuswamyPosted Jan 13, 2016, 10:41 AM
Thanks for nice article. i have small suggestion i feel not covered architecture of angularjs
Humayun Kabir MamunPosted Jan 11, 2016, 11:06 PM
Nice...
Ankit SaxenaPosted Jan 11, 2016, 12:50 PM
Good informative post. Thanks for sharing
Ankur MistryPosted Jan 11, 2016, 12:10 PM
Nice share
Ehsan SajjadPosted Jan 11, 2016, 11:40 AM
Good. keep writing
Nanddeep NachanPosted Jan 11, 2016, 10:23 AM
Thanks for sharing!
Arul RPosted Jan 11, 2016, 8:21 AM
Nice share
Mohammed IbrahimPosted Jan 11, 2016, 2:57 AM
nice
Ankit BansalPosted Jan 11, 2016, 1:41 AM
Nice...keep sharing..