Skip to main content

Posts

Showing posts from February, 2018

Explain AngularJS $watch(), $digest() and $apply()

$watch()  The $scope.watch() function is used to observe changes in a variable on the $scope. It accepts three parameters: expression, listener and equality object where listener and equality object are optional parameters. <html> <head>  <title>AngularJS Watch</title>  <script src="lib/angular.js"></script>  <script>  var myapp = angular.module("myapp", []);  var myController = myapp.controller("myController", function ($scope) {   $scope.name = 'nikssangani.blogspot.in';   $scope.counter = 0;   $scope.$watch('name', function (newValue, oldValue) {   $scope.counter = $scope.counter + 1;   });  });  </script> </head> <body ng-app="myapp" ng-controller="myController">  <input ng-model="name" type="text" />  Counter: </body> </html> $digest()  The $scope.$digest() function iterates through a

Getting 'Cross-Origin Request Blocked' on a GET request.

In this article, I will explain how to avoid cross-origin error in Web API. Just add "cors" packages from NuGet package manager and add this code in WebApiConfig.cs file. using System.Web.Http.Cors; public static class WebApiConfig { public static void Register(HttpConfiguration config) { var corsAttr = new EnableCorsAttribute(BusLib.Config.Configuration.CorsOrigin, "*", "*"); config.EnableCors(corsAttr); } }

Prevent Duplicate(Double) Inserts when Page is refreshed in Asp.net(C#).

In this article I will explain the most common issue faced by many ASP.Net Developers i.e. Prevent Duplicate Insertion of Record on Page Refresh in ASP.Net. Duplicate Inserts and Double updates occur when a page is refreshed after an insert or update statement of SQL Server is executed and we get a following popup from the browser. After insert or update statement is executed you can redirect the user to the same page. Response.Redirect(Request.Url.AbsoluteUri);