Uninstall and Reinstall Angular

We are interested in a specific angular version and NOT in a specific angular-cli version (angular-cli is just a tool after all).

Here are the steps (All these steps are done in npm);

If you’re not sure of the angular-cli version installed in your environment, uninstall it.

npm uninstall -g @angular/cli

Then, run (–force flag might be required).

npm cache clean

or, if you’re using npm > 5.

npm cache verify

Install an angular-cli specific version.

npm install -g @angular/cli@wished.version.here

Create a project

ng new you-app-name

The resulting white app will be created in the desired angular version.

I have not found any page displaying the compatibility matrix of angular and angular-cli. So I guess the only way to know what angular-cli version should be installed is to try various versions, create a new project and checkout the package.json to see which angular version is used.

angular versions changelog Here is the changelog from github reposition, where you can check available versions and the differences.

Reference

https://stackoverflow.com/questions/43344600/how-to-install-a-specific-version-of-angular-with-angular-cli

Angular 17 Local Install

Follow Steps To Install Angular CLI locally.

Disclaimer: I have Angular 16 Installed Globally. and will be installing 17 Locally (To install globally, follow this)

Create a folder in your local drive, say AngularTest.

> mkdir AngularTest
> cd AngularTest

Install your angular version (Make sure while installation you are not using -g at the end of the installation command);

> npm install @angular/cli@  (for any other version)
> npm install @angular/cli   (for current version)

Type following command in your AngularTest folder to confirm your version

> ng version

This will list down version for Angular CLI, Node, Package Manager and OS. If Angular is not compatible with Node, you will see a yellow message at the bottom of window. In that case you need to figure out correct node version for Angular.

Cheers!

You may be interested in Angular Getting Started Guide.

If you want to uninstall angular, follow this

What does –net=host option in Docker command really do?

After the docker installation you have 3 networks by default:

If you start a container by default it will be created inside the bridge (docker0) network.

$ docker run -d jenkins
1498e581cdba        jenkins             "/bin/tini -- /usr..."   3 minutes ago 

The –net=host option is used to make the programs inside the Docker container look like they are running on the host itself, from the perspective of the network. It allows the container greater network access than it can normally get.

Normally you have to forward ports from the host machine into a container, but when the containers share the host’s network, any network activity happens directly on the host machine – just as it would if the program was running locally on the host instead of inside a container.

While this does mean you no longer have to expose ports and map them to container ports, it means you have to edit your Dockerfiles to adjust the ports each container listens on, to avoid conflicts as you can’t have two containers operating on the same host port. However, the real reason for this option is for running apps that need network access that is difficult to forward through to a container at the port level.

For example, if you want to run a DHCP server then you need to be able to listen to broadcast traffic on the network, and extract the MAC address from the packet. This information is lost during the port forwarding process, so the only way to run a DHCP server inside Docker is to run the container as –net=host.

Generally speaking, –net=host is only needed when you are running programs with very specific, unusual network needs.

Lastly, from a security perspective, Docker containers can listen on many ports, even though they only advertise (expose) a single port. Normally this is fine as you only forward the single expected port, however if you use –net=host then you’ll get all the container’s ports listening on the host, even those that aren’t listed in the Dockerfile. This means you will need to check the container closely (especially if it’s not yours, e.g. an official one provided by a software project) to make sure you don’t inadvertently expose extra services on the machine.

Reference

https://stackoverflow.com/questions/43316376/what-does-net-host-option-in-docker-command-really-do

Store Complex Object in TempData

To pass object from controller method to controller method use this extension methid;

public static class TempDataExtensions
{
    public static void Put<T>(this ITempDataDictionary tempData, string key, T value) where T : class
    {
        tempData[key] = JsonConvert.SerializeObject(value);
    }

    public static T Get<T>(this ITempDataDictionary tempData, string key) where T : class
    {
        object o;
        tempData.TryGetValue(key, out o);
        return o == null ? null : JsonConvert.DeserializeObject<T>((string)o);
    }
}

And, you can use them as follows:

Say objectA is of type ClassA. You can add this to the temp data dictionary using the above mentioned extension method like this:

TempData.Put("key", objectA);

And to retrieve it you can do this:

var value = TempData.Get<ClassA>("key") where value retrieved will be of type ClassA

To configure TempData in ASP.NET Core, Refer to this article

Reference

https://stackoverflow.com/questions/34638823/store-complex-object-in-tempdata