Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
第 10 天 別說呂布了,你聽過青銅五小強嗎 |Template-driven-form、ngModel、Template variables
- Loading branch information
Showing
15 changed files
with
179 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<h1>新增英雄</h1> | ||
<app-hero-information-form></app-hero-information-form> |
25 changes: 25 additions & 0 deletions
25
src/app/pages/add-hero-page/add-hero-page.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { AddHeroPageComponent } from './add-hero-page.component'; | ||
|
||
describe('AddHeroPageComponent', () => { | ||
let component: AddHeroPageComponent; | ||
let fixture: ComponentFixture<AddHeroPageComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ AddHeroPageComponent ] | ||
}) | ||
.compileComponents(); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(AddHeroPageComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
|
||
@Component({ | ||
templateUrl: './add-hero-page.component.html', | ||
styleUrls: ['./add-hero-page.component.css'] | ||
}) | ||
export class AddHeroPageComponent implements OnInit { | ||
|
||
constructor() { } | ||
|
||
ngOnInit(): void { | ||
} | ||
|
||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<p>edit-hero-page works!</p> |
25 changes: 25 additions & 0 deletions
25
src/app/pages/edit-hero-page/edit-hero-page.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { EditHeroPageComponent } from './edit-hero-page.component'; | ||
|
||
describe('EditHeroPageComponent', () => { | ||
let component: EditHeroPageComponent; | ||
let fixture: ComponentFixture<EditHeroPageComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ EditHeroPageComponent ] | ||
}) | ||
.compileComponents(); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(EditHeroPageComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
|
||
@Component({ | ||
templateUrl: './edit-hero-page.component.html', | ||
styleUrls: ['./edit-hero-page.component.css'] | ||
}) | ||
export class EditHeroPageComponent implements OnInit { | ||
|
||
constructor() { } | ||
|
||
ngOnInit(): void { | ||
} | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
src/app/shared/components/hero-information-form/hero-information-form.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<div class="form-field"> | ||
<label for="name">NAME</label> | ||
<input | ||
#tName="ngModel" | ||
name="name" | ||
ngModel | ||
required | ||
type="text" | ||
id="name" /> | ||
</div> | ||
|
||
<button | ||
type="button" | ||
[disabled]="tName.invalid"> | ||
儲存 | ||
</button> | ||
|
18 changes: 18 additions & 0 deletions
18
src/app/shared/components/hero-information-form/hero-information-form.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
textarea, input { | ||
&.ng-invalid.ng-touched { | ||
border: 1px solid red; | ||
} | ||
} | ||
|
||
.form-field { | ||
display: flex; | ||
flex-direction: column; | ||
margin-bottom: 8px; | ||
} | ||
|
||
form { | ||
padding-top: 32px; | ||
width: 50%; | ||
min-width: 300px; | ||
margin: 0 auto; | ||
} |
25 changes: 25 additions & 0 deletions
25
src/app/shared/components/hero-information-form/hero-information-form.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { HeroInformationFormComponent } from './hero-information-form.component'; | ||
|
||
describe('HeroInformationFormComponent', () => { | ||
let component: HeroInformationFormComponent; | ||
let fixture: ComponentFixture<HeroInformationFormComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ HeroInformationFormComponent ] | ||
}) | ||
.compileComponents(); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(HeroInformationFormComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
15 changes: 15 additions & 0 deletions
15
src/app/shared/components/hero-information-form/hero-information-form.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'app-hero-information-form', | ||
templateUrl: './hero-information-form.component.html', | ||
styleUrls: ['./hero-information-form.component.scss'] | ||
}) | ||
|
||
export class HeroInformationFormComponent implements OnInit { | ||
|
||
constructor() {} | ||
|
||
ngOnInit(): void {} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters