search
HomeWeb Front-endJS TutorialProject preparation and environment building operations in Angular4

This article mainly introduces the preparation of Angular4 study notes and the environment construction project, which has certain reference value. Interested friends can refer to

The nonsense written in front 1

When I used Angular, it was still version 1. I am an engineer who switched from j2ee to Android, which means that my daily development language is Java. It was really uncomfortable to suddenly switch to JavaScript, like a polar bear talking to a penguin, not to mention that later I felt that webstorm was too laggy and I used sublime without prompts (well, I finally cured the "never remembering function names syndrome" that had been a problem for many years). After a painful experience of hitting the wall, I finally started to get used to it.

But I still want to yell, JavaScriptWCNM.

After venting, let’s get down to business.

The main front-end framework now is React. Although Angular is backed by Google, it is still a little behind. I have used both. Let me talk about the characteristics of Angular and the differences between it and React.

First of all, it is unfair to compare Angular and React directly. Because Angular is a family bucket that has everything, React is just the V in MVC, and it often needs to be used with other things such as redux (the standard configuration I use is react+redux+router). .

Secondly, Angular is characterized by binding, which is more in line with the concept of MVC from the perspective of writing code. The component in 4.0 is equivalent to the combination of C and V, template or templateUrl is the view, and class is the so-called controller. By declaring the only Model in the Controller to be used in the corresponding View, the purpose of decoupling is achieved. Moreover, Angular also supports injecting services to further separate business logic.

The characteristic of React is actually virtual dom, which is a speed-up thing. Redux is logically related and decoupled through a unique state. You change the state and I change the value. The ideas of both are very similar. Personally, I feel that the reducer in Redux is the service in Angular.

Third, which one is better? Personally, I still like React more. Of course, this subjective factor plays a large role. When I was writing Angular, I was still a resentful Android programmer, and when I was writing React, I was already an entry-level front-end developer.

Nonsense written in front 2

Some preparation work is necessary.

node, the basis of everything.

sublime, this is the IDE I use personally. I have used webstorm before, but it requires registration and is somewhat slow. However, the small disadvantage of using sublime is that you need to download the plug-in yourself. Webstorm is indeed more versatile... Subime's support for React is quite good, but its support for Angular is still a bit awkward. Of course, it's also possible that I didn't install the correct plug-in.

git, this project has been submitted to github. Of course, the level of updating is inversely proportional to my level of laziness. In fact, I have already completed this project, but it was deleted due to some mysterious power from the East (let’s be honest, I’m just cheap)...

Good English, not required. But if you are good at English, you can go directly to the official website of Angular, the portal, it will be faster if you can bypass the wall. The Chinese version of Angular is still stuck at 2.0, and the writing method is slightly different from 4.0.

Of course there is not much difference between 4.0 and 2.0, at least it is much smaller than the difference between 2.0 and 1. There are 2 but not 3 because I feel that most of the time I only need to commit two.

Let’s talk about demand first - any project without demand is just a joke! flow! Hooligan!

The requirements are very simple, and it basically imitates the preparation page of Super Robot Wars (yes, I am a Gundam fan and I happen to be playing Robot Wars Z recently).

First of all, this project contains 3 pages:

1 Home page


Project preparation and environment building operations in Angular4
The upper part shows the project Description, the lower half selects 3 bodies and gives a brief explanation.

2 Aircraft list page


Project preparation and environment building operations in Angular4# Aircraft display, showing all owned airframes, including name and status (in order to prevent Project preparation and environment building operations in Angular4 infringement, use It’s a Gunpla that I made myself).

3 Body details page


Project preparation and environment building operations in Angular4Click on any body from the homepage and details page to jump to this page, which mainly introduces the body Various parameters, basic situation and status.

Environment setup

First you need node and sublime, and then you need to use sublime's package manager to install the plug-in typescript.

For how to install node and sublime package managers and download plug-ins, please refer to the methods in previous articles.

Secondly, you can use sourceTree or the command line to clone the address:

1) The official quickstart given by angular

##
https://github.com/angular/quickstart.git

2) Mine The advantage of the adapted version is that it integrates webpack and scss. The disadvantage is that the writing is messy and I don’t know what the pitfalls are.

https://github.com/stormrabbit/gundam-meister.git

Third, npm install installs various dependencies.

If the installation fails, you can consider using cnpm

cnpm:


npm install -g cnpm --registry=http://r.cnpmjs.org
npm install microtime --registry=http://r.cnpmjs.org --disturl=http://dist.cnpmjs.org

假装安装一下

Project preparation and environment building operations in Angular4

运行命令 npm start

Project preparation and environment building operations in Angular4

目录结构:

Project preparation and environment building operations in Angular4

src/main.ts 项目的入口文件 暂时不需要修改

src/index.html 项目展示的html,容器,相当于java的虚拟机,标签是自定义的component的标签化。

src/app/app.module.ts 项目的配置文件,所用的component、注册的service以及以后会有的routing等等都会注册到这里。相当于Android的mainfist.xml文件。

src/app/component/appcomponent/app.component.ts 项目的第一个容器,也是项目的正式入口。相当于java中的main函数,Android中的MainActivity。当然也不是一定要叫这个名字,不过是一种约定俗成。其中template是html页面,相当于view,class相当于controller。

访问http://localhost:3000/,显示页面

Project preparation and environment building operations in Angular4

环境搭建完毕,hello,world。

The above is the detailed content of Project preparation and environment building operations in Angular4. 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
From Websites to Apps: The Diverse Applications of JavaScriptFrom Websites to Apps: The Diverse Applications of JavaScriptApr 22, 2025 am 12:02 AM

JavaScript is widely used in websites, mobile applications, desktop applications and server-side programming. 1) In website development, JavaScript operates DOM together with HTML and CSS to achieve dynamic effects and supports frameworks such as jQuery and React. 2) Through ReactNative and Ionic, JavaScript is used to develop cross-platform mobile applications. 3) The Electron framework enables JavaScript to build desktop applications. 4) Node.js allows JavaScript to run on the server side and supports high concurrent requests.

Python vs. JavaScript: Use Cases and Applications ComparedPython vs. JavaScript: Use Cases and Applications ComparedApr 21, 2025 am 12:01 AM

Python is more suitable for data science and automation, while JavaScript is more suitable for front-end and full-stack development. 1. Python performs well in data science and machine learning, using libraries such as NumPy and Pandas for data processing and modeling. 2. Python is concise and efficient in automation and scripting. 3. JavaScript is indispensable in front-end development and is used to build dynamic web pages and single-page applications. 4. JavaScript plays a role in back-end development through Node.js and supports full-stack development.

The Role of C/C   in JavaScript Interpreters and CompilersThe Role of C/C in JavaScript Interpreters and CompilersApr 20, 2025 am 12:01 AM

C and C play a vital role in the JavaScript engine, mainly used to implement interpreters and JIT compilers. 1) C is used to parse JavaScript source code and generate an abstract syntax tree. 2) C is responsible for generating and executing bytecode. 3) C implements the JIT compiler, optimizes and compiles hot-spot code at runtime, and significantly improves the execution efficiency of JavaScript.

JavaScript in Action: Real-World Examples and ProjectsJavaScript in Action: Real-World Examples and ProjectsApr 19, 2025 am 12:13 AM

JavaScript's application in the real world includes front-end and back-end development. 1) Display front-end applications by building a TODO list application, involving DOM operations and event processing. 2) Build RESTfulAPI through Node.js and Express to demonstrate back-end applications.

JavaScript and the Web: Core Functionality and Use CasesJavaScript and the Web: Core Functionality and Use CasesApr 18, 2025 am 12:19 AM

The main uses of JavaScript in web development include client interaction, form verification and asynchronous communication. 1) Dynamic content update and user interaction through DOM operations; 2) Client verification is carried out before the user submits data to improve the user experience; 3) Refreshless communication with the server is achieved through AJAX technology.

Understanding the JavaScript Engine: Implementation DetailsUnderstanding the JavaScript Engine: Implementation DetailsApr 17, 2025 am 12:05 AM

Understanding how JavaScript engine works internally is important to developers because it helps write more efficient code and understand performance bottlenecks and optimization strategies. 1) The engine's workflow includes three stages: parsing, compiling and execution; 2) During the execution process, the engine will perform dynamic optimization, such as inline cache and hidden classes; 3) Best practices include avoiding global variables, optimizing loops, using const and lets, and avoiding excessive use of closures.

Python vs. JavaScript: The Learning Curve and Ease of UsePython vs. JavaScript: The Learning Curve and Ease of UseApr 16, 2025 am 12:12 AM

Python is more suitable for beginners, with a smooth learning curve and concise syntax; JavaScript is suitable for front-end development, with a steep learning curve and flexible syntax. 1. Python syntax is intuitive and suitable for data science and back-end development. 2. JavaScript is flexible and widely used in front-end and server-side programming.

Python vs. JavaScript: Community, Libraries, and ResourcesPython vs. JavaScript: Community, Libraries, and ResourcesApr 15, 2025 am 12:16 AM

Python and JavaScript have their own advantages and disadvantages in terms of community, libraries and resources. 1) The Python community is friendly and suitable for beginners, but the front-end development resources are not as rich as JavaScript. 2) Python is powerful in data science and machine learning libraries, while JavaScript is better in front-end development libraries and frameworks. 3) Both have rich learning resources, but Python is suitable for starting with official documents, while JavaScript is better with MDNWebDocs. The choice should be based on project needs and personal interests.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool