Home > Web Front-end > JS Tutorial > body text

AngularJS environment building tutorial

小云云
Release: 2018-01-02 09:50:46
Original
1456 people have browsed it

This article mainly introduces the process of setting up the AngularJS environment for beginners. The features of Angular-cli are mentioned in the article. Let's take a look at it. I hope it can help beginners successfully build an AngularJS environment.

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

AngularJS Features

AngularJS is a powerful JavaScript-based development framework for creating Rich Internet Applications (RIA).

AngulajJS provides developers 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 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.;

Yes The function of webpack can realize code separation, on-demand loading, etc.;

automatically configures the development environment, test environment, and production environment, can realize code packaging and compression and hot deployment, and can also realize module testing and end-to-end Test

Angular-cli can automatically identify the pre-compilation 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 the best practice and can be used in the production environment;

2. Install nodejs

AngularJS needs to use Nodejs, so we need to first To install nodejs, you need to 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 others from the NPM server Write third-party packages 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 written by themselves to the NPM server for others to use.

The installation of nodejs and npm has been completed here, but 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, execute the command

npm i -g cnpm

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

After installing cnpm, we start to install Angular-cli.

Execute the command

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 directly create the project 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 in the browser: http://localhost:4200 and you can directly access:

5. Import the project

If it is How do we start a project locally if we find it online? Let’s do it in detail:

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

. For the demonstration here, we also use a project of Teacher Da Mo: NiceFish , first we need to clone the project through git, which will not be demonstrated 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.

Execute command

cnpm i -g @angular/cli

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

Wait for the command execution to complete, then execute the command

cnpm install

Then execute the command

ng serve -prod -aot

Then wait for the compilation to complete.

After completion, we can enter in the browser:

http://localhost:4200 to access the project.

Related recommendations:

Detailed tutorial on how to build a vue, node, and webpack environment with graphic examples

A simple tutorial on how to build a vue environment with detailed examples

The clearest graphic tutorial on building a PHP server environment

The above is the detailed content of AngularJS environment building tutorial. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!