Home  >  Article  >  Web Front-end  >  Detailed explanation of the steps to build AngularJS environment

Detailed explanation of the steps to build AngularJS environment

php中世界最好的语言
php中世界最好的语言Original
2018-04-16 14:06:071358browse

This time I will bring you a detailed explanation of the steps to build the AngularJS environment. What are the precautions for building the AngularJS environment? The following is a practical case, let’s take a look.

What is AngularJS?

AngularJS is an open source web application framework. It was originally developed in 2009 by MISKO Hevery and Adam Abrons. Now maintained by Google

AngularJSFeatures

AngularJS is a powerful JavaScript-based development framework for creating rich Internet applications (RIA). AngulajJS provides developers with the option (

Using JavaScript

) to write client-side applications in a clean MVC (Model-View-Controller) way. Applications written in AngularJS are cross-browser compatible. AngularJS uses JavaScript code to automatically handle adaptation to each browser.

AngularJS is open source, completely free, and is developed and maintained by thousands of developers around the world. It is released under the Apache License version 2.0.

Overall, AngularJS is a framework for building large-scale, high-performance web applications while making them easy to maintain.

1. Here is a brief introduction to the features of Angular-cli: Angular-cli can quickly build a framework and create modules, services, classes, directives, etc.;

It has the function of webpack, which can realize code separation, on-demand loading, etc.;

Automatically

configure the development environment

, test environment, and production environment, which can realize code packaging, compression and hot deployment, as well as module testing and end-to-end testing Angular-cli can automatically identify the precompilation of sass and less through the suffix;

Angular-cli can configure TypeScript when creating, and can also make some personalized configurations;

The project structure created through Angular-cli is a best practice and can be used in production environments;

2. Install nodejs AngularJS requires Nodejs, so we need to install nodejs first and use nodejs. The download address of nodejs is: https://nodejs.org/en/download/,

3. Install npm and cnpm The next step is to install npm,

NPM is a package management tool installed along with NodeJS. It can solve many problems in NodeJS code deployment. Common usage scenarios include the following:

Allow users to download third-party packages written by others from the NPM server for local use.

Allows users to download and install command line programs written by others from the NPM server for local use.

Allows users to upload packages or command line programs they write to the NPM server for others to use.

The installation of nodejs and npm has been completed here. However, there will be some problems if you use npm to install it in Datianchao, so we use cnpm to install it, which is also a package of npm.

Install cnpm and execute command

npm i -g cnpm

After executing this command, wait for completion, and then enter cnpm version to check whether the installation is complete. I have already installed it here, so I can go in.

After installing cnpm, we start installing Angular-cli.

Excuting an order

cnpm i -g angular-cli

Then you can execute the ng version command to check whether the installation is complete and the version of angular-cli

After the installation is complete, we can use the ng command and start

Creating the project

.

4. Project creation After installing angular-cli, you can create the project directly and execute the command

ng new JustForTest

Where JustForTest is the project name

Executing this command creates a lot of files, and you need to wait for a while. This step will take a long time, and you need to wait until the installation of nod_.modules is completed

Start directly using ng serve.

In this way, you can start the project directly. We enter: http://localhost:4200 in the browser to directly access:

5. Importing the project

If we are looking for a project online, how do we start it locally? Let’s do it in detail:

I recommend everyone to take a look at this tutorial by Teacher Da Mo: Angular2.0 video tutorial is here

, here we also use a project of Teacher Da Mo: NiceFish. First we need to clone the project through git. We will not demonstrate this here. This is the project address of NiceFish: http://git.oschina.net/mumu -osc/NiceFish

After the project is cloned, the command line enters the directory where the project is located.

Excuting an order

cnpm i -g @angular/cli

Let me explain here, we installed the global angular-cli before.

Wait for the command execution to complete before executing the command

cnpm install

Then execute the command

ng serve -prod -aot

Then wait for the compilation to complete.

Once completed, we can enter in the browser:

http://localhost:4200 Access the project.

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:



The above is the detailed content of Detailed explanation of the steps to build AngularJS environment. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn