Home  >  Article  >  Web Front-end  >  How to build a web server with AngularJS? The detailed process of building a web server with angularjs

How to build a web server with AngularJS? The detailed process of building a web server with angularjs

寻∝梦
寻∝梦Original
2018-09-08 16:59:542304browse

This article mainly introduces the operation of starting the web server in angularjs. I hope it can help everyone. Let’s start reading the article now

Install node.js

Download link

Official website address: https://nodejs.org/en/
The decompressed version I downloaded, directly decompress it into the directory you want to install.
In My Computer (right click)→Properties→Advanced System Variables→Environment Variables

Write NODE_PATH

How to build a web server with AngularJS? The detailed process of building a web server with angularjs

##Add to In path

node -v How to build a web server with AngularJS? The detailed process of building a web server with angularjsThe node version can be displayed on the console

 v6.11.4
Install the Web server

npm install connect
npm install serve-static

Write the server.js file, as shown in the book The version is version 2.x, now it is version 3.x, the code in the book is invalid, put the file in the nodejs installation directory

var connect = require('connect');
    serveStatic = require('serve-static');
var app = connect();
app.use(serveStatic("../angularjs"));
app.listen(5000);

AngularJS settings

Create a new angularjs folder and nodejs installation directory level


How to build a web server with AngularJS? The detailed process of building a web server with angularjs

In the folder, you need to prepare the bootstrap css file and angular.js

angularjs folder download address: click to download
Create a new FirstTest.html in the angularjs folder

<!DOCTYPE html><html ng-app><head>
    <title> First Test</title>
    <script src="angular.js"></script>
    <link href="bootstrap.css" rel="stylesheet" />
    <link href="bootstrap-grid.css" rel="stylesheet" /></head><body>
    <p class="btn btn-dark">{{ "AngularJS" }}</p>
    <p class="btn btn-success">Bootsstrap</p></body></html>

Start the web server

Jump to the nodejs installation directory

node server.js

View the browser http://localhost:5000/FirstTest .html

The effect is as follows:


How to build a web server with AngularJS? The detailed process of building a web server with angularjs

This article ends here (if you want to see more, go to the PHP Chinese website

AngularJS User Manual column), if you have any questions, you can leave a message below.

The above is the detailed content of How to build a web server with AngularJS? The detailed process of building a web server with angularjs. 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