Showing posts with label Javascript. Show all posts
Showing posts with label Javascript. Show all posts

Saturday, 1 October 2016

Create a sample Angular 2 application with basic structure and setup for bootstrap using Typescript

In this post we are going to see the basic structure and setup for developing a angular2 single page application using Typescript, In angular2 lot of release are released by angular team, each and every release had lot of break through changes, even in the last release it have many changes from the Previous one, so we cant say which is correct way of development, each and every versions have different things in coding and setup. 


Now let we see what is the basic structure needed for develop a Angular 2 applications, in this sample we will use the Typescript for development. and we will create a Hello world sample.

First we will configure the basic things needed for project like configs.

Step 1. Setup the package.json
Step 2. Setup the tsconfig.json
Step 3. Setup the typings.json
Step 4. Create the systemjs.config.js
Step 5. Create the main.ts typescript file
Step 6. Run the npm
Step 7. Add the index.html file
Step 8. Create a component
Step 9. Create and Bootstrap a module
Step 10. Add the component in index.html and Start the npm

Now we create step by step


1. Setup the package.json, 

Create a folder name "angular applications", under that folder create a file package.json

 package.json
{
    "name": "Angular2",
    "description": "This projects deals with angular samples",
    "version": "1.0.0",
    "scripts": {
        "start": "tsc && concurrently \"tsc -w\" \"lite-server\" ",
        "lite": "lite-server",
        "postinstall": "typings install",
        "tsc": "tsc",
        "tsc:w": "tsc -w",
        "typings": "typings"
    },
    "dependencies": {
        "@angular/common": "~2.0.1",
        "@angular/compiler": "~2.0.1",
        "@angular/core": "~2.0.1",
        "@angular/forms": "~2.0.1",
        "@angular/http": "~2.0.1",
        "@angular/platform-browser": "~2.0.1",
        "@angular/platform-browser-dynamic": "~2.0.1",
        "@angular/router": "~3.0.1",
        "@angular/upgrade": "~2.0.1",
        "angular-in-memory-web-api": "~0.1.1",
        "bootstrap": "^3.3.7",
        "core-js": "^2.4.1",
        "reflect-metadata": "^0.1.8",
        "rxjs": "5.0.0-beta.12",
        "systemjs": "0.19.39",
        "zone.js": "^0.6.25"  
    },
    "devDependencies": {
         "concurrently": "^3.0.0",
         "lite-server": "^2.2.2",
         "typescript": "^2.0.3",
         "typings":"^1.4.0"
    }    
}


 In Above config you may find few key things, the important things are dependencies, devDependencies, scripts, in dependencies we have to add the dependent files which needs to download using the npm package manager, in devdependencies we have to configure additional things like server, typings, typescript version. In scripts section we can configure the postinstall settings and lite server inputs to compile and watch the files





2. Setup the tsconfig.json

Create a file name tsconfig,json , which is a configuration file used for typescript.

tsconfig,json
    
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false
  }
}





3. Setup the typings.json
    
Create a file named typings.json in which we can define additional typings

typings.json
{
  "globalDependencies": {
    "core-js": "registry:dt/core-js#0.0.0+20160725163759",
    "jasmine": "registry:dt/jasmine#2.2.0+20160621224255",
    "node": "registry:dt/node#6.0.0+20160909174046"
  }
}





4. Create the systemjs.config.js

Now create a system config file which is used to define the basic things like module to be load by System.js, it is basically config file for System.js, Here we can define the paths and there bundles with short names which can be used through out the applications, Create a module pattern function inside that call a System.Config


systemjs.config.js
(function (global) {
    
    System.config({
        
        paths:{
            'npm:': 'node_modules/'
        },

        map: {
            // our app is within the app folder
            app: 'com',
            // angular bundles
            '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
            '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
         '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
            
    '@angular/platform-browser': 
       'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
            
    '@angular/platform-browser-dynamic': 
'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
       
            '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
            '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
            '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
            // other libraries
            'rxjs':                      'npm:rxjs',
            'angular-in-memory-web-api': 'npm:angular-in-memory-web-api',
         },

    // packages tells the System loader how to load when no filename 
    packages: {
            com: {
                main: './main.js',
                defaultExtension: 'js'
            },
            rxjs: {
                defaultExtension: 'js'
            },
            'angular-in-memory-web-api': {
                main: './index.js',
                defaultExtension: 'js'
            }
         }

    });

})(this);





5. Create the main.ts typescript file

Next important thing is we have to create main.ts file , Create a folder name com, then create a file name main.ts under that, Here we have to do the few important things , i.e bootstrap the module which is present under the application, if we have an component in index.html then the module in which it is present needs to be bootstrap, To bootstrap we have to create a platform specific bootstrap named   platformBrowserDynamic , using this we have to bootstrap the module

main.ts
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

const platform = platformBrowserDynamic();




6. Run the npm 

Now we have to install the packages using the npm, to do this first we have to install the node package manager in our system, then do the following steps.

  1. open the command prompt
  2. go to the root folder path of your application in your command prompt
  3. type npm install, which will install all packages includes in packages.json later it will run the post install the typings

Now node_modules are created inside your root folder.


7.  Add the index.html file

     Now we have to create a index.html file in the root folder which will load default in angular applications

<html>
  <head>
    <title>Angular QuickStart</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="node_modules/bootstrap/dist/css/bootstrap.css">
    <link rel="stylesheet" href="style.css">

    <!-- 1. Load libraries -->
     <!-- Polyfill(s) for older browsers -->
    <script src="node_modules/core-js/client/shim.min.js"></script>
    <script src="node_modules/zone.js/dist/zone.js"></script>
    <script src="node_modules/reflect-metadata/Reflect.js"></script>
    <script src="node_modules/systemjs/dist/system.src.js"></script>
      
    <script src="lib/jquery.js"></script>
    <script src="node_modules/bootstrap/dist/js/bootstrap.js"></script>
  

    <!-- 2. Configure SystemJS -->
    <script src="systemjs.config.js"></script>
    
    <script>
      System.import('com').catch(function(err){ 
          console.error(err); 
        });
    </script>

  </head>
  <!-- 3. Display the application -->
  <body>
   
  </body>
</html>




8. Create a component

Next step is to create a component for our application , now we create a helloComponent, first create helloComponent.ts file under "com" folder

helloComponent.ts
import { Component, ViewEncapsulation } from '@angular/core';

@Component({
    selector:'hello-app',
    template:'<h1>Hello {{name}}</h1>',
    encapsulation:ViewEncapsulation.None    
})
export class HelloComponent{
    name:string = "Rajesh G";
}





9. Create and Bootstrap a module

Next step is add the helloComponent to the HelloModule and bootstrap that module, Create a hello.module.ts file under the com folder

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';

import { HelloComponent } from'./hello.component'

@NgModule({
    imports:[BrowserModule],
    exports:[],
    declarations:[HelloComponent],
    bootstrap:[HelloComponent]
})

export class HelloModule{
    
}


Now add something configuration in the main.ts to bootstrap the module, adding the HelloModule in the bootstrap

import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { HelloModule } from './hello.module'

const platform = platformBrowserDynamic();

let moduleref = platform.bootstrapModule(HelloModule);




10. Add the component in index.html and Start the npm

        Now we are adding that component in the index.html , inside the body tag

<body>
    <hello-app>Loading...</hello-app>
  </body>


then we have to start the server by following steps,Now run the npm package manager from command prompt

1. Go to the command prompt and iterate to the root folder of your application 
2. Type npm start which will start the server and load the application in browser.




Output:
**********************












From this post you can learn how to setup a basic Angular2 applications, still we can except many changes in stable releases also,to reach a well matured product phase.

Saturday, 9 January 2016

Display the collection and total no of records along with the delete operation in angular js

In this post we are going to see How to display the collection in Html and the Total number of records using angular js, additionally we will have the delete operation so whenever a delete happens the records should be updated the count in the UI.

HTML :
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>


<div ng-controller="HomeController">
</head>
<body ng-app="app">

<script src="angular.js"  type="application/javascript"></script>
<script src="app.js" type="application/javascript"></script>


    <ul style="list-style: none;">
        <li style="padding: 10px;background-color: lightgray;margin: 5px;width: 300px;
                      text-align: center"
            ng-repeat="item in DataItems">
            <span>{{item}}</span>
            <span style="position: relative;right: -140px;">
                <input type="button" ng-click="remove(item)" value="X"> </span>
        </li>
        <div>Total Records : {{DataItems.length}}</div>
    </ul>
</div>


</body>
</html>

App.Js
var app = angular.module('app',[]);

app.controller('HomeController', ['$scope',function ($scope) {


        $scope.DataItems = [1,2,3,4,5,6,7];

        $scope.remove = function (id) {
            $scope.DataItems.splice($scope.DataItems.indexOf(id),1);
        }

    }]);


you can see the below output , that the initial collection is display as List along with the total records count, when the user delete the data, then automatically the count is updated correctly

Output







From this post you can learn how to do the iteration in collection and display in the UI along with delete operation

Friday, 25 December 2015

Create a Movies windows store app using the Html5 and Javascript

In this post we are going to see how to create a Windows Store App using Html5 and Javascript, This app can be run in windows 10 and Windows 8.1.

In this post we are trying to get the following result 







First we see something about the Windows App, In Windows App WinRT is the Key core which is used to create the App, We can create App in various combination ways.  

HTML5+CSS+Javascript  , 
HTML5+CSS+Javascript+C#,
 XAML+C#

Now in this post we are going to see how to create a app using the HTML5, First create a project in Javascript language, select the Window8 menu and Blank App(Windows 8.1)








Then here two files are mandatory we are going to start coding, default.html and default.js. Data binding to UI logic resides in default.js. To do the development we need to add some CSS coding one in the default.css and another one for grouplisting in the file groupitems.css

default.css:
#contenthost {
    height100%;
    width100%;
}

.fragment {
    /* Define a grid with rows for a banner and a body */
    -ms-grid-columns1fr;
    -ms-grid-rows128px 1fr;
    display-ms-grid;
    height100%;
    width100%;
}

.fragment header[role=banner] {
  /* Define a grid with columns for the back button and page title. */
  -ms-grid-columns37px 83px 1fr;
  -ms-grid-rows1fr;
   display-ms-grid;
 }

.fragment header[role=banner] .win-navigation-backbutton {
  -ms-grid-column2;
   margin-top57px;
   positionrelative;
   z-index1;
}

.fragment header[role=banner] .titlearea {
   -ms-grid-column3;
    margin-top37px;
}

.fragment header[role=banner] .titlearea .pagetitle {
   widthcalc(100% - 20px);
 }

.fragment section[role=main] {
  -ms-grid-row2;
  height100%;
}


groupitems.css:
.groupeditemspage section[role=main] {
    -ms-grid-row1;
    -ms-grid-row-span2;
}

.groupeditemspage .groupeditemslist {
    height100%;
    positionrelative;
    width100%;
    z-index0;
}

    /* This selector is used to prevent ui-dark/light.css from overwriting changes
       to .win-surface. */
    .groupeditemspage .groupeditemslist .win-horizontal.win-viewport .win-surface {
        margin-bottom60px;
        margin-left45px;
        margin-right115px;
        margin-top128px;
    }

    .groupeditemspage .groupeditemslist.win-rtl .win-horizontal.win-viewport .win-surface {
        margin-left115px;
        margin-right45px;
    }

    .groupeditemspage .groupeditemslist .win-groupheader {
        padding0;
    }

    /* Use grid and top level layout for truncation */
    .groupeditemspage .groupeditemslist .group-header {
        -ms-grid-columnsminmax(0, max-content) 7px max-content;
        -ms-grid-rowsmax-content;
        display-ms-inline-grid;
        line-height1.5;
    }

    /* Override default button styles */
    .groupeditemspage .groupeditemslist .group-header.group-header:hover
    .group-header:hover:active {
        backgroundtransparent;
        border0;
        margin-bottom1px;
        margin-left5px;
        margin-right5px;
        margin-top1px;
        min-height0;
        padding0;
    }

      .groupeditemspage .groupeditemslist .group-header .group-title {
            displayinline-block;
        }

     .groupeditemspage .groupeditemslist .group-header .group-chevron {
            -ms-grid-column3;
            displayinline-block;
      }

     .groupeditemspage .groupeditemslist .group-header .group-chevron::before {
                content"\E26B";
                font-family'Segoe UI Symbol';
      }

            .groupeditemspage .groupeditemslist .group-header 
.group-chevron:-ms-lang(ar, dv, fa, he, ku-Arab, pa-Arab, prs, ps, sd-Arab, syr, ug, ur, qps-plocm)::before {
                content"\E26C";
            }

   .groupeditemspage .groupeditemslist .item {
        -ms-grid-columns1fr;
        -ms-grid-rows1fr 90px;
        display-ms-grid;
        height250px;
        width200px;
    }

        .groupeditemspage .groupeditemslist .item .item-image {
            -ms-grid-row-span2;
        }

        .groupeditemspage .groupeditemslist .item .item-overlay {
            -ms-grid-row2;
            -ms-grid-rows1fr 21px;
            backgroundrgba(0, 0, 0, 0.65);
            display-ms-grid;
            padding6px 15px 2px 15px;
        }

            .groupeditemspage .groupeditemslist .item .item-overlay .item-title {
                -ms-grid-row1;
                colorrgba(255, 255, 255, 0.87);
                overflowhidden;
                width220px;
            }

            .groupeditemspage .groupeditemslist .item .item-overlay .item-subtitle {
                -ms-grid-row2;
                colorrgba(255, 255, 255, 0.6);
                width220px;
            }

@media screen and (-ms-high-contrast) {
    .groupeditemspage .groupeditemslist .item .item-overlay {
        colorWindowText;
    }
}


Now after created the CSS, now we concentrate on Data logic Let we create a Collection with some values then Bind that to a Binding.List class, later CreateGroup from that List , then bind to the WinControl.

var groupItems = [];
                groupItems = [
                    {key:"Action",title:"Action",subtitle:"",imageUrl:"",
                       description:"This section deals with the Action Movies"},
                    { key: "Drama", title: "Drama", subtitle: "", imageUrl: ""
                       description: "This section deals with the Drama Movies" },
                    { key: "Cartoon", title: "Cartoon", subtitle: "", imageUrl: ""
                       description: "This section deals with the Cartoon Movies" },
                    { key: "SciFi", title: "SciFi", subtitle: "", imageUrl: ""
                       description: "This section deals with the SciFi Movies" },
                    { key: "Love", title: "Love", subtitle: "", imageUrl: ""
                       description: "This section deals with the Love Movies" }
                ];

                var items = [];
                items = [
                    { group:groupItems[0], title: "The Dark Night"
                      subtitle:"Hero with many ideas",description:"", Story:""
                      imageUrl: "Content/images/darknight.jpg", },
                    { group: groupItems[1], title: "Face Off", subtitle: ""
                      description: "", Story: "", imageUrl: "Content/images/faceoff.jpg",  },
                    { group:groupItems[0], title: "Avengers", subtitle:"",description:""
                      Story:"",imageUrl: "Content/images/avengars.jpg", },
                    { group:groupItems[1], title: "KingsMan", subtitle:"",description:""
                      Story:"",imageUrl: "Content/images/kingsman.jpg", },
                    { group: groupItems[1], title: "Mad Fury", subtitle: "", description: "",                        Story: "", imageUrl: "Content/images/madfury.jpg" },
                    { group: groupItems[0], title: "The Matrix", subtitle: "",description: ""                        ,Story: "", imageUrl: "Content/images/matrix.jpg",  },
                    {group:groupItems[2],  title: "Tarzan", subtitle:"",description:""
                       Story:"",imageUrl: "Content/images/tarzan.jpg", },
                    { group:groupItems[2], title: "Lion King", subtitle:"",description:""
                      Story:"",imageUrl: "Content/images/lionking.jpg", },
                    { group:groupItems[4], title: "One I Love", subtitle:"",description:""
                      Story:"",imageUrl: "Content/images/oneilove.jpg", },
                    { group: groupItems[0], title: "Furious 7", subtitle: "", description: ""
                      , Story: "", imageUrl: "Content/images/furious7.jpg",  },
                    { group: groupItems[3], title: "The Terminator", subtitle: ""
                   description: "", Story: "", imageUrl: "Content/images/terminator.jpg",  },
                    { group: groupItems[3], title: "Star Wars", subtitle: "", description: ""
                        , Story: "", imageUrl: "Content/images/starwars.jpg", },
                    { group: groupItems[4], title: "Holiday", subtitle: "", description: ""
                       Story: "", imageUrl: "Content/images/holiday.jpg", },
                    { group: groupItems[4], title: "Love Story", subtitle: "",description: ""
                      , Story: "", imageUrl: "Content/images/lovestory.jpg", },
                    { group: groupItems[4], title: "Before SunRise", subtitle: ""
                  description: "", Story: "", imageUrl: "Content/images/beforesunrise.jpg", }
                ];

       

                /* Binding List from array */
                var itemBindingList = new WinJS.Binding.List(items);

                /* Create a Grouped items from List */
                var moviesGenre = itemBindingList.createGrouped(
                    function (item) { return item.group.key},
                    function (item) { return { group: item.group }; }
                    );

                /* Bind the data to control from the Grouped data */
                var listViewControl = document.getElementById("moviesAlbum").winControl;
                listViewControl.itemDataSource = moviesGenre.dataSource;
                listViewControl.groupDataSource = moviesGenre.groups.dataSource;



We have to place the above code inside the callback of WinJS.UI.processAll().done which is present inside the args.setpromise .

var app = WinJS.Application;
var activation = Windows.ApplicationModel.Activation;

Now we see the full source in Js side



Source Code default.js:

(function () {
    "use strict";

    var app = WinJS.Application;
    var activation = Windows.ApplicationModel.Activation;

    app.onactivated = function (args) {
        if (args.detail.kind === activation.ActivationKind.launch) {
            if (args.detail.previousExecutionState !== activation.ApplicationExecutionState.terminated) {
               
            } else {
                
            }
            args.setPromise(WinJS.UI.processAll().done(function () {                             

            var groupItems = [];
                groupItems = [
                    {key:"Action",title:"Action",subtitle:"",imageUrl:"",
                       description:"This section deals with the Action Movies"},
                    { key: "Drama", title: "Drama", subtitle: "", imageUrl: ""
                       description: "This section deals with the Drama Movies" },
                    { key: "Cartoon", title: "Cartoon", subtitle: "", imageUrl: ""
                       description: "This section deals with the Cartoon Movies" },
                    { key: "SciFi", title: "SciFi", subtitle: "", imageUrl: ""
                       description: "This section deals with the SciFi Movies" },
                    { key: "Love", title: "Love", subtitle: "", imageUrl: ""
                       description: "This section deals with the Love Movies" }
                ];

                var items = [];
                items = [
                    { group:groupItems[0], title: "The Dark Night"
                      subtitle:"Hero with many ideas",description:"", Story:""
                      imageUrl: "Content/images/darknight.jpg", },
                    { group: groupItems[1], title: "Face Off", subtitle: ""
                      description: "", Story: "", imageUrl: "Content/images/faceoff.jpg",  },
                    { group:groupItems[0], title: "Avengers", subtitle:"",description:""
                      Story:"",imageUrl: "Content/images/avengars.jpg", },
                    { group:groupItems[1], title: "KingsMan", subtitle:"",description:""
                      Story:"",imageUrl: "Content/images/kingsman.jpg", },
                    { group: groupItems[1], title: "Mad Fury", subtitle: "", description: "",                        Story: "", imageUrl: "Content/images/madfury.jpg" },
                    { group: groupItems[0], title: "The Matrix", subtitle: "",description: ""                        ,Story: "", imageUrl: "Content/images/matrix.jpg",  },
                    {group:groupItems[2],  title: "Tarzan", subtitle:"",description:""
                       Story:"",imageUrl: "Content/images/tarzan.jpg", },
                    { group:groupItems[2], title: "Lion King", subtitle:"",description:""
                      Story:"",imageUrl: "Content/images/lionking.jpg", },
                    { group:groupItems[4], title: "One I Love", subtitle:"",description:""
                      Story:"",imageUrl: "Content/images/oneilove.jpg", },
                    { group: groupItems[0], title: "Furious 7", subtitle: "", description: ""
                      , Story: "", imageUrl: "Content/images/furious7.jpg",  },
                    { group: groupItems[3], title: "The Terminator", subtitle: ""
                   description: "", Story: "", imageUrl: "Content/images/terminator.jpg",  },
                    { group: groupItems[3], title: "Star Wars", subtitle: "", description: ""
                        , Story: "", imageUrl: "Content/images/starwars.jpg", },
                    { group: groupItems[4], title: "Holiday", subtitle: "", description: ""
                       Story: "", imageUrl: "Content/images/holiday.jpg", },
                    { group: groupItems[4], title: "Love Story", subtitle: "",description: ""
                      , Story: "", imageUrl: "Content/images/lovestory.jpg", },
                    { group: groupItems[4], title: "Before SunRise", subtitle: ""
                  description: "", Story: "", imageUrl: "Content/images/beforesunrise.jpg", }
                ];

                      
                /* Binding List from array */
                var itemBindingList = new WinJS.Binding.List(items);

                /* Create a Grouped items from List */
                var moviesGenre = itemBindingList.createGrouped(
                    function (item) { return item.group.key},
                    function (item) { return { group: item.group }; }
                    );

                /* Bind the data to control from the Grouped data */
              var listViewControl =    document.getElementById("moviesAlbum").winControl;
                listViewControl.itemDataSource = moviesGenre.dataSource;
                listViewControl.groupDataSource = moviesGenre.groups.dataSource;



            }));
        }
    };

    app.oncheckpoint = function (args) {

    };

    app.start();
})();





Source Code default.html:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>CalcApp</title>

    <!-- WinJS references -->
    <link href="//Microsoft.WinJS.2.0/css/ui-dark.css" rel="stylesheet" />
    <script src="//Microsoft.WinJS.2.0/js/base.js"></script>
    <script src="//Microsoft.WinJS.2.0/js/ui.js"></script>

    <!-- CalcApp references -->
    <link href="/css/default.css" rel="stylesheet" />
    <link href="Content/css/groupitems.css" rel="stylesheet" />
    <script src="/js/default.js"></script>
</head>
<body>

    <!-- These templates are used to display each item in the ListView declared below. -->
    <div class="headertemplate" data-win-control="WinJS.Binding.Template">
        <button class="group-header win-type-x-large win-type-interactive" role="link" tabindex="-1" type="button">
            <span class="group-title win-type-ellipsis" data-win-bind="textContent: group.title"></span>
            <span class="group-chevron"></span>
        </button>
    </div>

    <div class="itemtemplate" data-win-control="WinJS.Binding.Template">
        <div class="item">
            <img class="item-image" src="#" data-win-bind="src: imageUrl; alt: title" />
            <div class="item-overlay">
                <h4 class="item-title" data-win-bind="textContent: title"></h4>
                <h6 class="item-subtitle win-type-ellipsis" data-win-bind="textContent: subtitle"></h6>
            </div>
        </div>
    </div>

    <!-- The content that will be loaded and displayed. -->
    <div class="fragment groupeditemspage">
        <header aria-label="Header content" role="banner">
            <button data-win-control="WinJS.UI.BackButton"></button>
            <h1 class="titlearea win-type-ellipsis">
                <span class="pagetitle">Movies List</span>
            </h1>
        </header>
        <section aria-label="Main content" role="main">
            <div id="moviesAlbum" class="groupeditemslist win-selectionstylefilled"
                aria-label="List of groups" 
                data-win-control="WinJS.UI.ListView" 
                data-win-options="{
                    layout: {type: WinJS.UI.GridLayout, groupHeaderPosition: 'top'},                                    
                    groupHeaderTemplate: select('.headertemplate'),                   
                    itemTemplate: select('.itemtemplate'),                  
                }">
            </div>
        </section>
    </div>
</body>
</html>


data-win-control, data-win-options , data-win-bind are the key attributes which use in the application.


Output:
************












From the above post you can learn how to create a Windows store App using the Html5 and Javascript