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
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.

From C/C   to JavaScript: How It All WorksFrom C/C to JavaScript: How It All WorksApr 14, 2025 am 12:05 AM

The shift from C/C to JavaScript requires adapting to dynamic typing, garbage collection and asynchronous programming. 1) C/C is a statically typed language that requires manual memory management, while JavaScript is dynamically typed and garbage collection is automatically processed. 2) C/C needs to be compiled into machine code, while JavaScript is an interpreted language. 3) JavaScript introduces concepts such as closures, prototype chains and Promise, which enhances flexibility and asynchronous programming capabilities.

JavaScript Engines: Comparing ImplementationsJavaScript Engines: Comparing ImplementationsApr 13, 2025 am 12:05 AM

Different JavaScript engines have different effects when parsing and executing JavaScript code, because the implementation principles and optimization strategies of each engine differ. 1. Lexical analysis: convert source code into lexical unit. 2. Grammar analysis: Generate an abstract syntax tree. 3. Optimization and compilation: Generate machine code through the JIT compiler. 4. Execute: Run the machine code. V8 engine optimizes through instant compilation and hidden class, SpiderMonkey uses a type inference system, resulting in different performance performance on the same code.

Beyond the Browser: JavaScript in the Real WorldBeyond the Browser: JavaScript in the Real WorldApr 12, 2025 am 12:06 AM

JavaScript's applications in the real world include server-side programming, mobile application development and Internet of Things control: 1. Server-side programming is realized through Node.js, suitable for high concurrent request processing. 2. Mobile application development is carried out through ReactNative and supports cross-platform deployment. 3. Used for IoT device control through Johnny-Five library, suitable for hardware interaction.

Building a Multi-Tenant SaaS Application with Next.js (Backend Integration)Building a Multi-Tenant SaaS Application with Next.js (Backend Integration)Apr 11, 2025 am 08:23 AM

I built a functional multi-tenant SaaS application (an EdTech app) with your everyday tech tool and you can do the same. First, what’s a multi-tenant SaaS application? Multi-tenant SaaS applications let you serve multiple customers from a sing

How to Build a Multi-Tenant SaaS Application with Next.js (Frontend Integration)How to Build a Multi-Tenant SaaS Application with Next.js (Frontend Integration)Apr 11, 2025 am 08:22 AM

This article demonstrates frontend integration with a backend secured by Permit, building a functional EdTech SaaS application using Next.js. The frontend fetches user permissions to control UI visibility and ensures API requests adhere to role-base

JavaScript: Exploring the Versatility of a Web LanguageJavaScript: Exploring the Versatility of a Web LanguageApr 11, 2025 am 12:01 AM

JavaScript is the core language of modern web development and is widely used for its diversity and flexibility. 1) Front-end development: build dynamic web pages and single-page applications through DOM operations and modern frameworks (such as React, Vue.js, Angular). 2) Server-side development: Node.js uses a non-blocking I/O model to handle high concurrency and real-time applications. 3) Mobile and desktop application development: cross-platform development is realized through ReactNative and Electron to improve development efficiency.

The Evolution of JavaScript: Current Trends and Future ProspectsThe Evolution of JavaScript: Current Trends and Future ProspectsApr 10, 2025 am 09:33 AM

The latest trends in JavaScript include the rise of TypeScript, the popularity of modern frameworks and libraries, and the application of WebAssembly. Future prospects cover more powerful type systems, the development of server-side JavaScript, the expansion of artificial intelligence and machine learning, and the potential of IoT and edge computing.

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.