Microsoft Technologies, ASP.NET & SQL SERVER Tips with Rajat Jaiswal

Month: June 2014

Dear Friends,
In last post part 1 ,we learnt how to use Angular.js.
Now in this post we are moving further as I shared we will do some more interesting thing here.
In this demo I have created same type of JSON as we have created in last post but it has some more values likeMatchDate: ‘Localtime’, MatchNumber: ‘Match64’, GroupName: ‘Final’, Stadium: ‘Maracanã-EstádioJornalistaMárioFilho’, Venue: ‘RioDeJaneiro’, TeamName1: ‘W61’, TeamCode1: ‘W61’, TeamName2: ‘W62’, TeamCode2: ‘W62’

I created the JSON from FIFA.com’s data (I hope they will not mind it.)
Now as mention earlier, it is exactly same as we did in last post it has module, controller and groups properties.
In this we added two more features which is Order By & filter.
Firstly order by expression. So we have used order by expression in ng-repeat.

We have sorted this with matchDate with Order by expression as shown in below image

When you run it then your result will be in order by MatchDate

Now what if you want to sort it by reverse date order then it is also very simple you just need to add “-“minus sign in front of MatchDate once you will do this you will get following output.

Now we are interested in some specific information like particular group, particular match, and particular team so in such case we require Filter extension property.
In current example we have taken a textbox which has property ng-model. Now this ng-model value is passed in ng-repeat with filter option as shown in below image

Now when you type value in textbox you will get filtered result on the screen as

Dear Friends,
Today FIFA world cup 2014 is going to start, So I just thought to make something which have colors of FIFA world cup 2014 with my learning.
In this post I am sharing how to create a simple Angular.Js page in ASP.NET which give you FIFA 2014 Group Information.Step 1:- Add a new project of ASP.NET and add Angular.Js in the project you can download Angular.js from here.https://angularjs.org/
Or you can add angular js from NUGET package also.

Step 2:– Now add as JavaScript file. I have added myApp.js file in project
Now we need to create a JSON for groups as shown belowStep 3:- Add reference of Angular.js and myApp.js in your project,

Step 4:- Now next step is to add an Angular module to add this we need to write following line

var app = angular.module(‘App’, []);

Step 5: Once Module is added now we need to add a controller in this controller we need to declare a variable and assign JSON object which we have declare earlier.

Step 6: OK cool now your myAPP.js work is done.

Now move to design view of page. In this firstly assign the module to page
Currently I have assign this module in body tag.
Note: all the Angular related property started here with ng-
So in body tag I have written following property as shown in fig

Step 7:– Once we have added the module now we assign controller to a div in which we need JSON data of FIFA world cup 2014, So it can be added using ng-controller as shown in below fig

Step 7:- Now if you see JSON data it has multiple group like GROUP A , GROUP B etc so we require ng-repeat attribute of Angular.js. Tthis ng-repeat will reference controller’s variable which we have assigned in myapp.js.
Now for each group data we will create a div which have team name, team code, and team flag in that group. For this we need to write following code.

The best thing here is to access the property or value you just need to write curly barces {} and within this the property which you want to access.