Angular 初级笔记

# 1. 目录结构

# 根页面, 一般只包含 <app-root></app-root> 模块
src/index.html

# 程序入口
src/main.ts

# 根模块
# Root Component (<app-root></app-root>) 是所有组件的入口
src/app/app.module.ts
src/app/app.component.ts
src/app/app.component.html
src/app/app.component.css

# 其他模块,放到 app 子目录里。如 login 模块:
src/app/login/login.component.ts
src/app/login/login.component.html
src/app/login/login.component.css

# 2. 关于 <router-outlet></router-outlet>

这是位于起始组件 app.component.html 中的默认内容。

The router-outlet is a directive that's available from the @angular/router package and is used by the router to mark where in a template, a matched component should be inserted.

Thanks to the router outlet, your app will have multiple views/pages and the app template acts like a shell of your application. Any element, you add to the shell will be rendered in each view, only the part marked by the router outlet will be changed between views.

# 3. 常用命令

# service
$ ng g service _service/authentication
CREATE src/app/_service/authentication.service.spec.ts (397 bytes)
CREATE src/app/_service/authentication.service.ts (143 bytes)

# class
$ ng g class _model/user
CREATE src/app/_model/user.spec.ts (146 bytes)
CREATE src/app/_model/user.ts (22 bytes)