diff --git a/src/app/app.component.html b/src/app/app.component.html
index 437fe71..0113d22 100644
--- a/src/app/app.component.html
+++ b/src/app/app.component.html
@@ -1,5 +1,10 @@
-
-
+
+
+
+
+
+
+ 無待辦事項
+
diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts
deleted file mode 100644
index 6c98b2e..0000000
--- a/src/app/app.component.spec.ts
+++ /dev/null
@@ -1,35 +0,0 @@
-import { TestBed } from '@angular/core/testing';
-import { RouterTestingModule } from '@angular/router/testing';
-import { AppComponent } from './app.component';
-
-describe('AppComponent', () => {
- beforeEach(async () => {
- await TestBed.configureTestingModule({
- imports: [
- RouterTestingModule
- ],
- declarations: [
- AppComponent
- ],
- }).compileComponents();
- });
-
- it('should create the app', () => {
- const fixture = TestBed.createComponent(AppComponent);
- const app = fixture.componentInstance;
- expect(app).toBeTruthy();
- });
-
- it(`should have as title 'Learn'`, () => {
- const fixture = TestBed.createComponent(AppComponent);
- const app = fixture.componentInstance;
- expect(app.title).toEqual('Learn');
- });
-
- it('should render title', () => {
- const fixture = TestBed.createComponent(AppComponent);
- fixture.detectChanges();
- const compiled = fixture.nativeElement as HTMLElement;
- expect(compiled.querySelector('.content span')?.textContent).toContain('Learn app is running!');
- });
-});
diff --git a/src/app/app.component.ts b/src/app/app.component.ts
index fe3ea8e..816cc2f 100644
--- a/src/app/app.component.ts
+++ b/src/app/app.component.ts
@@ -1,28 +1,29 @@
-import { Component } from '@angular/core';
+import { Component, OnInit } from '@angular/core';
import { Task } from './task';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
- styleUrls: [ './app.component.css' ]
+ styleUrls: ['./app.component.css'],
})
-export class AppComponent {
- tasks: Task[] = [
- new Task({ TaskSn: '001', TaskName: '待辦事項 A', State: 'Finish' }),
- new Task({ TaskSn: '002', TaskName: '待辦事項 B', State: 'Doing' }),
- new Task({ TaskSn: '003', TaskName: '待辦事項 C', State: 'None' }),
- new Task({ TaskSn: '004', TaskName: '待辦事項 D', State: 'None' }),
- ];
- trackByItems(index:number, task:Task):string{
- return task.TaskSn;
+export class AppComponent implements OnInit {
+ tasks!: Task[];
+
+ ngOnInit(): void {
+ this.onLoad();
}
- onReset():void{
- this.tasks=[
+
+ onLoad(): void {
+ this.tasks = [
new Task({ TaskSn: '001', TaskName: '待辦事項 A', State: 'Finish' }),
new Task({ TaskSn: '002', TaskName: '待辦事項 B', State: 'Doing' }),
- new Task({ TaskSn: '004', TaskName: '待辦事項 C', State: 'None' }),
- new Task({ TaskSn: '005', TaskName: '待辦事項 D', State: 'None' }),
+ new Task({ TaskSn: '003', TaskName: '待辦事項 C', State: 'None' }),
+ new Task({ TaskSn: '004', TaskName: '待辦事項 D', State: 'None' }),
];
}
+
+ onClear(): void {
+ this.tasks = [];
+ }
}