ng-model Doesn't Work Inside ng-if | Scope Properties Doesn't Change inside ng-if | AngularJS Tutorial

If an ng-model is used inside an ng-if, then the model does not work as expected.

<div ng-app >
    <div ng-controller="main">

        Test A: {{testa}}<br />
        Test B: {{testb}}<br />
        Test C: {{testc}}<br />

            testa (without ng-if): <input type="checkbox" ng-model="testa" />
        <div ng-if="!testa">
            testb (with ng-if): <input type="checkbox" ng-model="testb" />
        <div ng-if="!someothervar">
            testc (with ng-if): <input type="checkbox" ng-model="testc" />

The ng-if directive will create a child scope. So the CheckBox changes the testb inside of the child scope and not the outer parent scope.

To modify the data in the parent scope, you'll need to make use of $parent as given below:

You can use $parent to refer to the model defined in the parent scope like this
<input type="checkbox" ng-model="$parent.testb" />

How to Convert Synchronous ASP.NET MVC Action to Asynchronous ASP.NET MVC Action | Asynchronous Support in ASP.NET MVC Controller | ASP.NET MVC Tutorial

In ASP.NET MVC controller action method receives data from a web request and passes the data to a view which then creates the HTML to be sent to the browser. Frequently the action method needs to get data from a database or web service in order to display it in a web page or to save data entered in a web page. In those scenarios it's easy to make the action method asynchronous: instead of returning an ActionResult object, you return Task<ActionResult> and mark the method with the async keyword. Inside the method, when a line of code kicks off an operation that involves wait time, you mark it with the await keyword.
Here is a simple action method that calls a repository method for a database query:
public ActionResult Index()
    string currentUser = User.Identity.Name;
    var result = fixItRepository.FindOpenTasksByOwner(currentUser);

    return View(result);
And here is the same method that handles the database call asynchronously:
public async Task<ActionResult> Index()
    string currentUser = User.Identity.Name;
    var result = await fixItRepository.FindOpenTasksByOwnerAsync(currentUser);

    return View(result);
Under the covers the compiler generates the appropriate asynchronous code. When the application makes the call toFindTaskByIdAsync, ASP.NET makes the FindTask request and then unwinds the worker thread and makes it available to process another request. When the FindTask request is done, a thread is restarted to continue processing the code that comes after that call. During the interim between when the FindTask request is initiated and when the data is returned, you have a thread available to do useful work which otherwise would be tied up waiting for the response.

Generating Unique Token in C# | Generating Unique Token that Expires after 24 Hours in C# | C# Tutorial

There are two possible approaches; either you create a unique value and store somewhere along with the creation time, for example in a database, or you put the creation time inside the token so that you can decode it later and see when it was created.
To create a unique token:
string token = Convert.ToBase64String(Guid.NewGuid().ToByteArray());
Basic example of creating a unique token containing a time stamp:
byte[] time = BitConverter.GetBytes(DateTime.UtcNow.ToBinary());
byte[] key = Guid.NewGuid().ToByteArray();
string token = Convert.ToBase64String(time.Concat(key).ToArray());
To decode the token to get the creation time:
byte[] data = Convert.FromBase64String(token);
DateTime when = DateTime.FromBinary(BitConverter.ToInt64(data, 0));
if (when < DateTime.UtcNow.AddHours(-24)) {
  // too old
Note: If you need the token with the time stamp to be secure, you need to encrypt it. Otherwise a user could figure out what it contains and create a false token.

Creating Cookie in ASP.NET MVC Action | Handling Cookies in ASP.NET MVC | Set Cookie Expiry in ASP.NET MVC | ASP.NET MVC Tutorial

We can create Cookie and set value to it in ASP.NET MVC Action method using the HttpCookie object using System.Web namespace. This created cookie should be added to HttpResponse object before returning the view in ASP.NET MVC Action method.

Below sample C# code demonstrated on how to create and set cookie in ASP.NET MVC Action method and pass it to Razor:

public ActionResult Index()
   HttpCookie cookie = new HttpCookie("cookie_name","cookie_value");
   cookie.Expires = DateTime.Now.AddDays(1);
   return View();
In detail:

To get a cookie:
HttpCookie cookie = HttpContext.Request.Cookies.Get("cookie_name");
To check for a cookie's existence:
HttpContext.Request.Cookies["cookie_name"] != null
To save a cookie:
HttpCookie cookie = new HttpCookie("cookie_name");
HttpContext.Response.SetCookie(cookie );

Removing an Item from Javascript Array | JavaScript Array pop() Method Example | JavaScript Tutorial

The pop() method removes the last element of an array, and returns that element. pop() method also changes the length of an array after removing the last element.

var fruits = ["Banana""Orange""Apple""Mango"];

The result of fruits will be:


Search Efficiently in Google | Google Search Tip and Tricks | How to do Advance Search in Google? | Google Search Guide

Accessing Parent Controller Scope in Child Controller in AngularJS | AngularJS Parent Controller Scope in Child Controller | AngularJS Tutorial

We can accessing Parent Controller Scope in Child Controller in AngularJS using $parent in $scope. Let us see an example below:
 If your HTML is like below you could do something like this:
<div ng-controller="ParentCtrl">
    <div ng-controller="ChildCtrl">
Then you can access the parent scope as follows
function ParentCtrl($scope) {
    $scope.cities = ["NY", "Amsterdam", "Barcelona"];

function ChildCtrl($scope) {
    $scope.parentcities = $scope.$parent.cities;
If you want to access a parent controller from your view you have to do something like this:
<div ng-controller="xyzController as vm">

What is meant by HTTP Status Response Code 205 Reset Content | HTTP Tutorial | HTTP Interview Question

The server has fulfilled the request and the user agent SHOULD reset the document view which caused the request to be sent. This response is primarily intended to allow input for actions to take place via user input, followed by a clearing of the form in which the input is given so that the user can easily initiate another input action. The response MUST NOT include an entity.