Module, Directives, Filter, Controller

An AngularJS module defines an application. The module is a container for the different parts of an application.
The module is a container for the application controllers. Controllers always belong to a module.
The module is created using angular.module, please see the example below

A module is created by using the AngularJS function angular.module
angular.module(“myAppMainModule”, []);

or

var app = angular.module(“myAppMainModule”, []);

Where [] contains the list of built-in angular services. We will learn about angular in later articles.

Defined module can be attached to HTML section using ng-app directive.

Example:

Angular JS provides a set of directives which help to achieve many functionalities easily in your application.
For example:
ng-app: directive initializes an AngularJS application.
ng-init: directive initializes application data.
ng-repeate: directive helps to repeat the data in the collection.

You can also add your own directives and use in your application.

AngularJS controllers control the data of AngularJS applications. AngularJS controllers are regular JavaScript Objects. AngularJS applications are controlled by controllers. The ng-controller directive defines the application controller.

Example:

First Name:
Last Name:

Full Name: {{firstName + ” ” + lastName}}

var app = angular.module(‘myApp’, []);
app.controller(‘myCtrl’, function($scope) {
$scope.firstName = “Izharuddin”;
$scope.lastName = “Shaikh”;
});

Filters can be added in AngularJS to format data. AngularJS provides filters to transform data:

currency: Format a number to a currency format.
date: Format a date to a specified format.
filter: Select a subset of items from an array.
json: Format an object to a JSON string.
limitTo: Limits an array/string, into a specified number of elements/characters.
lowercase: Format a string to lower case.
number: Format a number to a string.
orderBy: Orders an array by an expression.
uppercase: Format a string to upper case.

Example:

The name is {{ lastName | lowercase }}

#controller, #directives, #filter, #module

Introduction to Angular JS

AngularJS is a JavaScript-based open-source front-end web application framework mainly maintained by Google and by a community of individuals and corporations to address many of the challenges encountered in developing single-page applications.

Before we go in depth to understand what features Angular Js provide with respect to Single Page Application (SPA), let’s first understand the challenges we have with SPA.

The problems with SPA application includes DOM Manipulation, History, Routing, Ajax, Object Modeling, Data Binding, View Loading, Module Loading, Caching etc. With Angular, all the stuff already built in and there are various core libraries available to handle all these challenges.

Angular Js provides Two-way Data Binding, DOM manipulations can be done using jqLite or JQuery, In built routing, Templates, History tracking, Factories, Services, Validations, Controllers, Views, Directories and Dependency Injection.

#introduction-to-angular-js

Find Wait and Blocks In SQL

This query the sys.dm_os_waiting_tasks DMV to show all waiting tasks currently active or blocked,
revealing the wait type, duration, and resource

SELECT blocking.session_id AS blocking_session_id ,
blocked.session_id AS blocked_session_id ,
waitstats.wait_type AS blocking_resource ,
waitstats.wait_duration_ms ,
waitstats.resource_description ,
blocked_cache.text AS blocked_text ,
blocking_cache.text AS blocking_text
FROM sys.dm_exec_connections AS blocking
INNER JOIN sys.dm_exec_requests blocked ON blocking.session_id = blocked.blocking_session_id
CROSS APPLY sys.dm_exec_sql_text(blocked.sql_handle) blocked_cache
CROSS APPLY sys.dm_exec_sql_text(blocking.most_recent_sql_handle) blocking_cache
INNER JOIN sys.dm_os_waiting_tasks waitstats ON waitstats.session_id = blocked.session_id

Output:

o

#wait-and-blocks

Operators

Below is the list of operators used is C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApp
{
    class Operators
    {
        //Arithmetic: + - * / %
	//Assignment: = += -= /= %= ++ -- &= ^= != <>=
	//Comparision: == != > = <=
	//Logical operators: && || !
        //Bitwise operators: * | ^ <> ~
    }
}

#operators

Access Levels

Below is the example to understand the access modifier in C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApp
{
    public class AccessLevels
    {
        public AccessLevels() { 
        
        }
        public int intPublic; //unrestricted access.
        protected int intProtected;//own or derived class.
        internal int intInternal;//own assembly.
        protected internal int intProtectedInternal;//own assembly or derived.
        private int intPrivate;//own class only.

        //All are accessible in same class.
        public void AccessibleInSameClass() {
            intPublic = 0;
            intProtected = 0;
            intInternal = 0;
            intProtectedInternal = 0;
            intPrivate = 0;
        }
    }

    //Private members are not accessible in derived class.
    public class DerivedAccessLevels : AccessLevels {
        public void AccessibleLevels() {
            intPublic = 0;
            intProtected = 0;
            intInternal = 0;
            intProtectedInternal =0;
        }
    }

    //Only Public, Protected Internal And Internal are accessible in another class.
    public class AnotherClass {
        public void fnAccess(AccessLevels objAccessLevels) {
            objAccessLevels.intPublic = 0;
            objAccessLevels.intInternal = 0;
            objAccessLevels.intProtectedInternal = 0;
        }
    }
}

#access-modifier

Objects in C#

(Almost) Everything is an object is .net and C#. We all know that int, char, string, date, double etc are the primitive data types. But all these data types are derived from system.object.

To understand this lets take an example of int data type. We all know that int is derived from System.Int32; but we can declare the variable of int type using below mentioned two ways

int i = new int();
int j = 0;

where first option is like abject instance creation. When we use the . (dot) operator on i then it will give us different methods like .ToString(), .Equals() for object equality, .GetType() to get type. Hence this proves that all these primitives data types also derived from object (system.object) base class.

datatype

 

#object

Value Type and Reference Type

Value Type:

  • Small type that have their values allocated on the stack in memory.
  • Cannot be null; must always contain data.
  • When passed in method (by val), they are coped as new objects.So the original  value will never change only the copy will change.
  • Cost is low on performance and memory because values are small.
  • Derived from system.valuetype and are sealed (it cannot be inherited).

Reference Type:

  • Can consume significant resources but have more features.
  • Can be null and reference to heap-based (.Net managed) objects.
  • When passed in methods (by ref) only a reference to object is passed. Changes to reference data change the source.
  • No wasted resource because a copy of the object is not made.
  • Cost is an issue with performance and memory because references need to be managed by .Net and must be garbage collected.

 

#reference-type, #value-type