Angular-Redux 项目教程
angular-reduxAngular 4 and Redux simplified + Live Demo项目地址:https://gitcode.com/gh_mirrors/an/angular-redux
1. 项目的目录结构及介绍
angular-redux/
├── e2e/
│ ├── src/
│ │ ├── app.e2e-spec.ts
│ │ └── app.po.ts
│ ├── protractor.conf.js
│ └── tsconfig.e2e.json
├── src/
│ ├── app/
│ │ ├── components/
│ │ ├── containers/
│ │ ├── models/
│ │ ├── reducers/
│ │ ├── services/
│ │ ├── app-routing.module.ts
│ │ ├── app.component.css
│ │ ├── app.component.html
│ │ ├── app.component.spec.ts
│ │ ├── app.component.ts
│ │ └── app.module.ts
│ ├── assets/
│ ├── environments/
│ │ ├── environment.prod.ts
│ │ └── environment.ts
│ ├── index.html
│ ├── main.ts
│ ├── styles.css
│ ├── test.ts
│ ├── tsconfig.app.json
│ ├── tsconfig.spec.json
│ └── typings.d.ts
├── angular.json
├── package.json
├── tsconfig.json
└── tslint.json
目录结构介绍
- e2e/: 端到端测试目录,包含 Protractor 配置文件和测试脚本。
- src/: 源代码目录,包含应用程序的主要代码。
- app/: 应用程序的主要逻辑目录,包含组件、容器、模型、reducers、服务等。
- assets/: 静态资源目录,如图片等。
- environments/: 环境配置文件目录,包含开发和生产环境的配置。
- index.html: 应用程序的主 HTML 文件。
- main.ts: 应用程序的入口文件。
- styles.css: 全局样式文件。
- test.ts: 测试配置文件。
- tsconfig.app.json: TypeScript 配置文件,用于应用程序编译。
- tsconfig.spec.json: TypeScript 配置文件,用于测试编译。
- typings.d.ts: TypeScript 类型定义文件。
- angular.json: Angular CLI 配置文件。
- package.json: 项目依赖和脚本配置文件。
- tsconfig.json: 根目录下的 TypeScript 配置文件。
- tslint.json: TSLint 配置文件。
2. 项目的启动文件介绍
main.ts
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
if (environment.production) {
enableProdMode();
}
platformBrowserDynamic().bootstrapModule(AppModule)
.catch(err => console.error(err));
- enableProdMode(): 启用生产模式,禁用 Angular 的开发模式特性。
- platformBrowserDynamic(): 使用 JIT 编译器启动 Angular 应用程序。
- bootstrapModule(AppModule): 引导启动
AppModule
,这是应用程序的根模块。
3. 项目的配置文件介绍
angular.json
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"angular-redux": {
"projectType": "application",
"schematics": {},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/angular-redux",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app
angular-reduxAngular 4 and Redux simplified + Live Demo项目地址:https://gitcode.com/gh_mirrors/an/angular-redux