Thursday, 12 April 2018

004 AngularJS Numbers, Strings ,Objects ,Arrays

AngularJS : Number
AngularJS numbers are like JavaScript numbers , AngularJS Number can be Filter ,simple mathematical calculation is possible on Number . Number can be put under an Object. 

Below is the example of simple mathematical calculation.

Example

<!DOCTYPE >
          <head>
              <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
                </head>
                  <body>
                            <div ng-app="" ng-init="height=15;width=15">
                       <p>Total Area : {{ height * width }}</p>
             </div>
</body>

Output :
Total Area : 225

Below is the example of simple number is formatted to 2 decimal place.

Example

<!DOCTYPE >
       <head>
               <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
                </head>
                    <body>
                             <div ng-app="" ng-init="height=15">
                    <p><div>{{ height | currency: '' }}</div></p>
            </div>
</body>

Output :
15.00

AngularJS : String
AngularJS string are like JavaScript string ,AngularJS string can be Filter ,simple string operation , like concatenation ,sub string is possible.String can be put under an Object. 
 
Below is the example of string concatenation.string var1 , var2 is concatenated to an output.

Example

<!DOCTYPE >
<head>
                     <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
           </head>
             <body>
                              <div ng-app="" ng-init="var1='Angular';var2='JS'">
                              <p><div>{{ var1+ var2 }}</div></p>
                  </div>
</body>

Output :
AngularJS

Below is the example of string sub string.OriginalString is value is parted and stored in StringPart .

Example


<!DOCTYPE >
<head>
            <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
           </head>
           <script>
               var app = angular.module("myApp", []);
               app.controller("myCtroller", function ($scope)
               {
                          $scope.OriginalString = "";
                          $scope.StringPart = [];
                          $scope.DoPart = function ()
                          {
                              $scope.StringPart = $scope.OriginalString.substr(1, 4);
                          }
             });

         </script>
               <div ng-app="myApp" ng-controller="myCtroller" ng-init="OriginalString='I am Learing AngularJS'">
                    <button type="button" ng-click="DoPart()">
                   Click Me</button>
                   {{ StringPart }}
</div>

Output :
Click Me : am


AngularJS : Object
AngularJS object are like JavaScript object ,AngularJS object support nested object also.Object element and nested element can be accessible through AngularJS . AngularJS object also support loop.
 
Below is the example of simple object student , and student element can be accessible by (.).

Example
<!DOCTYPE >
    <head>
            <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
         </head>
          <div ng-app="" ng-init="student={name:'John',age:20}">
              <table>
                  <tr>
                    <td>Name :
                         </td>
                           <td>{{student.name}}
                         </td>
                  </tr>
                <tr>
            <td>Age :
                     </td>
                 <td>{{student.age}}
                     </td>
                   </tr>
</table>
</div>

Output:
Name : John
Age : 20

Below is the example of Complext Object , Object array is nested under object array.This object element is accessible by AngularJS.

Example


<!DOCTYPE >
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
</head>
<body ng-app="myapp">
<script>
               angular.module("myapp", [])
               .controller("myController", function ($scope) {
               $scope.person =
               [
                    { name: "User 1", age: 12, mark: [{ lang: 50, math: 80, geo: 60}] },
                    { name: "User 2", age: 18, mark: [{ lang: 60, math: 90, geo: 70}] },
                   { name: "User 3", age: 20, mark: [{ lang: 70, math: 100, geo: 80}] }
             ]
              });
</script>
<div ng-controller="myController">
        <table>
            <tr ng-repeat="obj in person">
            <td>
                   Name :
           </td>
                  <td>{{obj.name}}
            </td>
           <td>
                  Age :
           </td>
           <td>{{obj.age}}
           </td>
           <td>
             <span ng-repeat="subobj in obj.mark">Marks : {{subobj.lang}}|{{subobj.math}}|{{subobj.geo}}          </span>
         </td>
           </tr>
           </table>
         </div>
</body>


Output:
Name : User 1 Age : 12 Marks : 50|80|60
Name : User 2 Age : 18 Marks : 60|90|70
Name : User 3 Age : 20 Marks : 70|100|80 
 

AngularJS : Array
AngularJS numbers are like JavaScript array,array elementt can be added , edit , delete. AngularJS also support looping throught array.
Below is the example of array , myArray , is declared and access the array element .

Example

<!DOCTYPE >
<head>
         <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
</head>
      <div ng-app="" ng-init="myArray=[1,2,3,4,5]">
         <p>
          Array Result is <span ng-bind="myArray[2]"></span>
         </p>
</div>

Output:
Array Result is 3



Below is the example of array , add , detele of item.

Example

<!DOCTYPE >
<head>
             <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
</head>
          <body ng-app="myapp">
             <script>
              angular.module("myapp", [])

              .controller("myController", function ($scope) {
               $scope.items = ['User 1', 'User 2', 'User 3'];
               $scope.add = function () {
              $scope.items.push($scope.AddArr);
               };
              $scope.remove = function (DelIndex) {
              $scope.items.splice(DelIndex, 1);
             };
             });

</script>
<div ng-controller="myController">
<table>
<tr ng-repeat="x in items">
<td>
{{x}}
              </td>
                   </tr>
                       <tr>
                            <td>
                                <fieldset>
                                        <legend>Add Item to Array :</legend>
                                         <input type="text" ng-model="AddArr">
                                         <button type="button" ng-click="add()" value="ADD" />
                              <fieldset />
                              </td>
                          </tr>
                     <tr>
                          <td>
                                 <fieldset>
                                      <legend>Delete Item from Array :</legend>
                                          <input type="text" ng-model="DelIndex">
                                          <button type="button" ng-click="remove()" value="Remove" />
                                      <fieldset />
                               </td>
                      </tr>
              </table>
         </div>
</body>











 

003 LIFE CYCLE

An Asp.Net page has two part , C# and aspx file. When in ASP.NET page process , there are several steps in it. ASP.NET life cycles  includes.
  • Page process, dynamic output is generated.
  • Page class and application class are compiled dynamically.
  • Application and classes instance is created dynamically

Asp.net page life cycle has two part

  • Application life cycle
  • Page life cycle

Application lifecycle

  • An user  request to IIS  server  through browser.IIS fast check,  the extension that can be process by the IIS. If page is .aspx  extension , then it is pass by 'aspnet_isapi.dll' for next step of processing.Asp.Net can handled the type of file , that the extension has mapped to it.Asp.Net IIS can handle .aspx,ashx,.asmx file extension by default.

  • An ApplicatioManager class is created , to run application smoothly .The purpose of application manager to create a separate domain to separate application global variable from other application, running  in the same IIS server.

  • Now the new domain has created for the application, next need the hosting environment . HostingEnvironment  class is created to provide runtime requirement resources. It is called 'http runtime'.HostingEnvironment provide infomation about the files and folder ect. Response object like HttpContext, HttpRequest, and HttpResponse is iniialised .
  • After initialisation ,HttpApplication class instance is created.Global.asax file instance is created.
  • After HttpApplicationinstance creation , configured modules are created.processing work like validation of request ,URL Mapping is done.


ASP.Net page life cycle event


PreInit :  It uses
IsPostBack property to determine the pages is created first time or need to recreate again. Dynamic controller can be created. Master page can be set, theme can be set.SkinId can be set.


protected void Page_PreInit(object sender, EventArgs e)
{
         if (this.Page.IsPostBack)
        {
           //do some logic
        }

        this.MasterPageFile = "~/MywMaster.master";
        this.Page.Theme = "MyTheme";
        this.myControl.SkinID = "MyControlSkin";
}

Init: It fire when all control are initialized,
in  the stage , each control have a unique ID. Control property also initialized.skin settings have been applied.






protected void Page_Init(object sender, EventArgs e)

{


}

Init complete: Make sure that all control
initialization process completed.
 
protected void Page_InitComplete(object sender, EventArgs e)

{

}

Preload: Load ViewState to each control ,
load postback data to each control.
Page instance is created.



protected override void OnPreLoad(EventArgs e)

{


}

load: Dynamic control can be created.Database connection can be created.
IsPostBack property check the page is new or recreated.
Make all validation of controls ,isValid works .
This is the fast method of a page , after the page is loaded.




protected void Page_Load(object sender, EventArgs e)

 



}

LoadComplete: All control has been loaded ,ViewState ,ControlState
loaded.Load method already called.This method actually complete
Load method.





protected void Page_LoadComplete(object sender, EventArgs e)

{



}

OnPreRender: After all control created and ready to render in the page. Property cannot be changed. Data binding completed with the data source.Final stage of page load.




protected override void OnPreRender(EventArgs e)

{



}

UnLoad:cleanup the page instance.
Close all connections, close all files, instance of a class is dispose.





protected void Page_UnLoad(object sender, EventArgs e)

{



}


         Asp.Net pages  created in server memory , then it is sent to Browser an server release memory. This process , page initialisation, initialisation of control, restore control property and viewstate, control state maintain is done .


            There are lot of event  in between , that need to be handle each steps. There are several inbuilt events of ASP.Net ,  this event can we override to a custom event.

Page request:
IsPostBack property is used to trace either the page has newly created on existing page, it also be decided that the page can be retrieved from server cache memory or create newly.

Starting of page life cycle: A page life cycle start with request from user to the server through browser. Server response request. Ispostback property is used to trace the page  is newly created or making round trip from server. Master page  and UI culture is set from this page.


বাঙালির বেড়ানো সেরা চারটি ঠিকানা

  বাঙালি মানে ঘোড়া পাগল | দু একদিন ছুটি পেলো মানে বাঙালি চলল ঘুরতে | সে সমুদ্রই হোক , পাহাড়ি হোক বা নদী হোক। বাঙালির ...