Posts

Showing posts with the label AngularJs

Difference between array, arraylist, List, Hashtable, Dictionary and SortedList in c#

Basic difference is that arrays are of fixed size. Whereas an ArrayList implements the list data structure and can dynamically grow. While arrays would be more performance that a list, a list would be far more flexible since you don't need to know the required size initially. Array - represents an old-school memory array - kind of like a alias for a normal type[] array. Can enumerate. Can't grow automatically. I would assume very fast insertion, retrieve and speed. ArrayList - automatically growing array. Adds more overhead. Can enum., probably slower than a normal array but still pretty fast. These are used a lot in .NET List - one of my favorites - can be used with generics, so you can have a strongly typed array, e.g. List . Other than that, acts very much like ArrayList. Hashtable - plain old hashtable. O(1) to O(n) worst case. Can enumerate the value and keys properties, and do key/val pairs. Dictionary - same as above only strongly typed via generics, such a...

How do we make HTTP get and post calls in Angular?

To make HTTP calls we need to use the “$http” service of Angular. In order to use the http services you need to make provide the “$http” as a input in your function parameters as shown in the below code. function CustomerController($scope,$http) {  $scope.Add = function()  {             $http({ method: "GET", url: " http://localhost:8438/SomeMethod "     }).success(function (data, status, headers, config)   {                    // Here goes code after success   }  } } “$http” service API needs atleast three things:- •First what is the kind of call “POST” or “GET”. •Second the resource URL on which the action should happen. •Third we need to define the “success” function which will be executed once we get the response from the server. $http({ method: "GET", url: " http://localhost:8438/SomeM...

Explain $scope in AngularJs?

“$scope” is an object instance of a controller. “$scope” object instance get’s created when “ng-controller” directive is encountered. For example in the below code snippet we have two controllers “Function1” and “Function2”. In both the controllers we have a “ControllerName” variable. function Function1($scope) { $scope.ControllerName = "Function1";        } function Function2($scope) { $scope.ControllerName = "Function2"; } Now to attach the above controllers to HTML UI we need to use “ng-controller” directive. For instance you can see in the below code snippet how “ng-controller” directive attaches “function1” with “div1” tag and “function2” with “div2” tag. Instance of {{ControllerName}} created Instance of {{ControllerName}} created So this is what happens internally. Once the HTML DOM is created Angular parser starts running on the DOM and following are the sequence of events:- •The parser first finds “ng-controller” directive which is pointing t...

What are expressions in Angular?

Angular expressionsare unit of code which resolves to value. This code is written inside curly braces “{“. Below are some examples of angular expressions:- The below expression adds two constant values. Hide   Copy Code {{1+1}} The below expression multiplies quantity and cost to get the total value. Hide   Copy Code The value total cost is {{ quantity * cost }} The below expression displays a controller scoped variable. The value of Customer code is {{CustomerCode}} The value of Customer code is {{CustomerCode}}

What are controllers and need of ng-controller and ng-model in Angular?

“Controllers” are simple javascript function which provides data and logic to HTML UI. As the name says controller they control how data flows from the server to HTML UI. For example below is simple “Customer” controller which provides data via “CustomerName” and “CustomerCode” property and Add/ Update logic to save the data to database. function Customer($scope) {         $scope.CustomerName = "Shiv";         $scope.CustomerCode = "1001";         $scope.Add = function () {         }         $scope.Update = function () {         } } “ng-controller” is a directive.Controllers are attached to the HTML UI by using the “ng-controller” directive tag and the properties of the controller are attached by using “ng-model” directive. For example below is a simple HTML UI which is attached t...

Explain Directives in AngularJs

Directives are attributes decorated on the HTML elements. All directives start with the word “ng”. As the name says directive it directs Angular what to do. For example below is a simple “ng-model” directive which tells angular that the HTML textbox “txtCustomerName” has to be binded with the “CustomerName” property. Some of the most commonly used directives are ng-app,ng-controller and ng-repeat

What are controllers and need of ng-controller and ng-model in AngularJs?

“Controllers” are simple javascript function which provides data and logic to HTML UI. As the name says controller they control how data flows from the server to HTML UI. For example below is simple “Customer” controller which provides data via “CustomerName” and “CustomerCode” property and Add/ Update logic to save the data to database. function Customer($scope) {         $scope.CustomerName = "Shiv";         $scope.CustomerCode = "1001";         $scope.Add = function () {         }         $scope.Update = function () {         } } “ng-controller” is a directive.Controllers are attached to the HTML UI by using the “ng-controller” directive tag and the properties of the controller are attached by using “ng-model” directive. For example below is a simple HTML UI which is attached t...

Explain Directives in AngularJs?

Directives are attributes decorated on the HTML elements. All directives start with the word “ng”. As the name says directive it directs Angular what to do. For example below is a simple “ng-model” directive which tells angular that the HTML textbox “txtCustomerName” has to be binded with the “CustomerName” property. Hide  Some of the most commonly used directives are ng-app,ng-controller and ng-repeat