Skip to content

Matthrews/angular_study

Repository files navigation

angular_study

Angular12 Study

Lesson 1: Introduction

image-20220424195521118

image-20220424195724927

image-20220424195835653

image-20220424195918534

image-20220424200011147

Lesson 2: Setup and install

image-20220424200146391

Lesson 3: Files and folder structure

image-20220424201727104

image-20220424202921230

Lesson 4: Hello World | Apply first change

image-20220424203132755****

Lesson 5: What is interpolation

image-20220424203729966xxx.component.ts中定义的动态值可以在xxx.component.html中通过{{}}使用

variable, function, typeof, num+1. OK

new, ++ Error

Q: How to make dynamic class?

<h1 class="{{cls}}">Dynamic class</h1>
<!-- OR -->
<h1 class={{cls}}>Dynamic class</h1>

Lesson 6: Angular CLI & Important commands

image-20220424205312371

npm insstall -g @angular/cli@12.0.0
ng generate component login
# OR
ng g c login
ng generate module user
ng generate class Person
ng generate service api

Lesson 7: Component

image-20220424210752317

Q: How can we use components?

<app-login></app-login>

Lesson 8: Component with Inline Style & Template

image-20220424212100373

ng g c use-list --inline-style
ng g c cc-list --inline-template
ng g c vv-list --inline-template --inline-style

Lesson 9: What is module?

image-20220424213932843

Lesson 10: How to make and call function

image-20220424215231108

<button (click)="getName('cck')">Click me</button>

Lesson 10: Important Events

image-20220424220051592

Lesson 11: Get Input field Value

image-20220424221351921

Lesson 12: Make Counter

image-20220424222436171

Lesson 13: Basic style

image-20220424223454094

优先级:Inline Style > Internal Style > Global Style > Component Style

Lesson 14: Property Binding

image-20220424224514726

Conclusion: Property Binding is a better option s compreg to Interpolation

Lesson 15: If/Else Condition

image-20220424230017201

image-20220425084622390

<!-- <p *ngIf="show else ccb">Matthew</p> -->
<p *ngIf="show; then ccf else ccb">Matthew</p>
<ng-template #ccf>
  <p>Matthew</p>
</ng-template>
<ng-template #ccb>
  <p>Jansen</p>
</ng-template>

Lesson 17: Switch Case

image-20220425132044633

<div [ngSwitch]="color">
  <h1 *ngSwitchCase="'red'" style="color: red;">Red Color</h1>
  <h1 *ngSwitchCase="'green'" style="color: green;">Green Color</h1>
  <h1 *ngSwitchCase="'gray'" style="color: gray;">Gray Color</h1>
  <h1 *ngSwitchDefault>Unknown Color</h1>
</div>

Lesson 18: Loop in Angular

image-20220425234531887

<p *ngFor="let user of users">Name is {{user}}</p>

image-20220425235119213

<ul *ngFor="let listItem of list">
  <li>Name is {{listItem.name}}</li>
  <li>Phone is {{listItem.phone}}</li>
  <li>Email is {{listItem.email}}</li>

  <ul *ngFor="let account of listItem.accounts">
    <li>Account is {{account}}</li>
  </ul>
</ul>

Lesson 20: Style Binding

image-20220426000249378

<!-- <h1 style="color: green;">{{ title }}</h1> -->
<h1 [style.color]="'red'">{{ title }}</h1>
<h1 [style.color]="color">{{ title }}</h1>
<button (click)="updateColor()">Update Color</button>

Lesson 21: Header Component

![image-20220428232246421](/Users/opsmind/Library/Application Support/typora-user-images/image-20220428232246421.png)

Lesson 22: Form Component

![image-20220428233611925](/Users/opsmind/Library/Application Support/typora-user-images/image-20220428233611925.png)

![image-20220429224112431](/Users/opsmind/Library/Application Support/typora-user-images/image-20220429224112431.png)

Lesson 23: Add Bootstrap

![image-20220429225212208](/Users/opsmind/Library/Application Support/typora-user-images/image-20220429225212208.png)

Hoe to add css: https://howtojs.io/how-to-add-bootstrap-css-to-an-angular-12-application-in-multiple-ways/git

About

Angular12 Study

Resources

Stars

Watchers

Forks