فهرست منبع

feat: one test

202226701056 4 ماه پیش
والد
کامیت
85b9018bed

+ 10 - 2
src/app/edit-tag/edit-tag.component.html

@@ -1,2 +1,10 @@
-<ion-input (ionInput)="UserInput($event)" type="text" placeholder="请输入标签"></ion-input>
-<p>当前输入:{{userInputText}}</p><ion-input (click)="addTag()">添加标签</ion-input>
+<ion-input [value]="userInputText" (ionInput)="UserInput($event)" type="text" placeholder="请输入标签"></ion-input>
+<p>当前输入:{{userInputText}}</p><ion-input (click)="addTag()" class="nlue">添加标签</ion-input>
+
+
+@for(tag of tags;track tag){
+   <ion-chip>{{tag}}   <span (click)="deleteTag(tag)">X</span></ion-chip>
+}
+<!-- <ion-input (ionInput)="Ces($event)" type="text" placeholder="请在输入标签"></ion-input>
+<p>当前输入:{{shuru}}</p> 
+<ion-input (click)="addTag()">添加标签</ion-input> -->

+ 5 - 0
src/app/edit-tag/edit-tag.component.scss

@@ -0,0 +1,5 @@
+.nlue {
+width:50px;
+height: 50px;
+background-color: #1100ff;
+}

+ 23 - 5
src/app/edit-tag/edit-tag.component.ts

@@ -1,16 +1,17 @@
-import { Component, OnInit } from '@angular/core';
-import { IonInput } from "@ionic/angular/standalone";
+import { Component, EventEmitter, OnInit, Output } from '@angular/core';
+import { IonInput, IonChip } from "@ionic/angular/standalone";
 
 @Component({
   selector: 'app-edit-tag',
   templateUrl: './edit-tag.component.html',
   styleUrls: ['./edit-tag.component.scss'],
   imports:[
-    IonInput
+    IonInput,IonChip
   ],
   standalone: true,
 })
 export class EditTagComponent  implements OnInit {
+ 
   /**
    * 用户输入
    */
@@ -26,9 +27,26 @@ export class EditTagComponent  implements OnInit {
     addTag(){
       this.tags.push(this.userInputText)
       this.userInputText=""
+      this.onTagChange.emit(this.tags)
     }
-  constructor() { }
+    @Output()
+    onTagChange:EventEmitter<Array<string>>=new EventEmitter<Array<string>>()
 
+  constructor() { }
+  deleteTag(tag:string){
+let idx=this.tags.findIndex(item=>item==tag);
+this.tags.splice(idx,1)
+  }
   ngOnInit() {}
-
+  // shuru:string=""
+  // Ces(ev:any){
+  //   console.log(ev)
+  //   this.shuru=ev.detail.value
+  // }
+  // shuchu:Array<string>=[];
+  // Tianjia(){
+  //   this.shuchu.push(this.shuru)
+  //   this.shuru=""
+  //   this.onTa.emit(this.shuchu)
+  // }
 }

+ 10 - 0
src/app/page-test/page-test.component.html

@@ -0,0 +1,10 @@
+<app-explore-container name="Tab 1 page"></app-explore-container>
+
+<app-edit-tag (onTagChange)="setTagsValue($event)">1</app-edit-tag>
+<h1>父页面,从子组件输出事件获得属性</h1>
+<ul>
+@for (item of editTags; track item) {
+<li>{{item}}</li>
+}
+
+</ul>

+ 0 - 0
src/app/page-test/page-test.component.scss


+ 22 - 0
src/app/page-test/page-test.component.spec.ts

@@ -0,0 +1,22 @@
+import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
+
+import { PageTestComponent } from './page-test.component';
+
+describe('PageTestComponent', () => {
+  let component: PageTestComponent;
+  let fixture: ComponentFixture<PageTestComponent>;
+
+  beforeEach(waitForAsync(() => {
+    TestBed.configureTestingModule({
+      imports: [PageTestComponent],
+    }).compileComponents();
+
+    fixture = TestBed.createComponent(PageTestComponent);
+    component = fixture.componentInstance;
+    fixture.detectChanges();
+  }));
+
+  it('should create', () => {
+    expect(component).toBeTruthy();
+  });
+});

+ 24 - 0
src/app/page-test/page-test.component.ts

@@ -0,0 +1,24 @@
+import { Component, OnInit } from '@angular/core';
+import { ExploreContainerComponent } from '../explore-container/explore-container.component';
+import { EditTagComponent } from '../edit-tag/edit-tag.component';
+
+@Component({
+  selector: 'app-page-test',
+  templateUrl: './page-test.component.html',
+  styleUrls: ['./page-test.component.scss'],
+  standalone: true,
+  imports:[ExploreContainerComponent,EditTagComponent]
+})
+export class PageTestComponent  implements OnInit {
+
+  constructor() { }
+
+  ngOnInit() {}
+ 
+  editTags:Array<string>=[]
+
+  setTagsValue(ev:any){
+    console.log("setTagsValue   "+ev)
+    this.editTags=ev;
+      }
+}

+ 3 - 0
src/app/poem-analyse/poem-analyse.component.html

@@ -0,0 +1,3 @@
+<p>
+  poem-analyse works!
+</p>

+ 0 - 0
src/app/poem-analyse/poem-analyse.component.scss


+ 22 - 0
src/app/poem-analyse/poem-analyse.component.spec.ts

@@ -0,0 +1,22 @@
+import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
+
+import { PoemAnalyseComponent } from './poem-analyse.component';
+
+describe('PoemAnalyseComponent', () => {
+  let component: PoemAnalyseComponent;
+  let fixture: ComponentFixture<PoemAnalyseComponent>;
+
+  beforeEach(waitForAsync(() => {
+    TestBed.configureTestingModule({
+      imports: [PoemAnalyseComponent],
+    }).compileComponents();
+
+    fixture = TestBed.createComponent(PoemAnalyseComponent);
+    component = fixture.componentInstance;
+    fixture.detectChanges();
+  }));
+
+  it('should create', () => {
+    expect(component).toBeTruthy();
+  });
+});

+ 15 - 0
src/app/poem-analyse/poem-analyse.component.ts

@@ -0,0 +1,15 @@
+import { Component, OnInit } from '@angular/core';
+
+@Component({
+  selector: 'app-poem-analyse',
+  templateUrl: './poem-analyse.component.html',
+  styleUrls: ['./poem-analyse.component.scss'],
+  standalone: true,
+})
+export class PoemAnalyseComponent  implements OnInit {
+
+  constructor() { }
+
+  ngOnInit() {}
+
+}

+ 5 - 6
src/app/tab1/tab1.page.html

@@ -10,15 +10,14 @@
 
   <ion-header collapse="condense">
     <ion-toolbar>
-      <ion-title size="large">Tab 1</ion-title>
+      <ion-title size="large">刘鹏护体</ion-title>
     </ion-toolbar>
   </ion-header>
-<ion-button expand="block" size="large" color="tertiary"  (mouseup)="toRecordLearn">
+  <ion-button expand="block" size="large" color="tertiary" (click)="toRecordLearn()">
 <ion-icon slot="start" > </ion-icon>
 我的学习记录
 </ion-button>
-  <app-explore-container name="Tab 1 page"></app-explore-container>
-  <div>
-    <app-edit-tag>1</app-edit-tag>
-  </div>
+
+<ion-button (click)="goTestPage()">进入测试页面</ion-button>
+<ion-button (click)="goanalysePage()">进入测试页面</ion-button>
 </ion-content>

+ 13 - 4
src/app/tab1/tab1.page.ts

@@ -1,18 +1,27 @@
 import { Component } from '@angular/core';
 import { IonHeader, IonToolbar, IonTitle, IonContent, IonImg, IonCard, IonCardHeader, IonCardTitle, IonCardContent, IonButton, IonApp, IonText, IonLabel, IonItem, IonList, IonSegment, IonSegmentButton, IonTabButton, IonIcon, IonFooter, IonTabs, IonCol, IonGrid, IonRow } from '@ionic/angular/standalone';
-import { ExploreContainerComponent } from '../explore-container/explore-container.component';
-import {EditTagComponent} from  '../edit-tag/edit-tag.component'
+
+import { Router } from '@angular/router';
 
 @Component({
   selector: 'app-tab1',
   templateUrl: 'tab1.page.html',
   styleUrls: ['tab1.page.scss'],
   standalone: true,
-  imports: [IonIcon, IonTabButton, IonSegmentButton, IonSegment, IonList, IonItem, IonLabel, IonText, IonApp, IonButton, IonCardContent, IonCardTitle, IonCardHeader, IonCard, IonImg, IonHeader, IonToolbar, IonTitle, IonContent, ExploreContainerComponent,EditTagComponent],
+  imports: [IonIcon,IonButton,  IonHeader, IonToolbar, IonTitle, IonContent],
 })
 export class Tab1Page {
+
   toRecordLearn(){
     alert("记录学习情况,双击666")
   }
-  constructor() {}
+      constructor(private router:Router) {}
+      goTestPage() {
+        this.router.navigate(['/tabs/test']);
+      }
+      goanalysePage(){
+        this.router.navigate(['/tabs/poem/analyse']);
+      }
+
+      
 }

+ 10 - 0
src/app/tabs/tabs.routes.ts

@@ -21,6 +21,16 @@ export const routes: Routes = [
         loadComponent: () =>
           import('../tab3/tab3.page').then((m) => m.Tab3Page),
       },
+      {
+        path: 'test',
+        loadComponent: () =>
+          import('../page-test/page-test.component').then((m) => m.PageTestComponent),
+      },
+      {
+        path: '/poem/analyse',
+        loadComponent: () =>
+          import('../poem-analyse/poem-analyse.component').then((m) => m.PoemAnalyseComponent),
+      },
       {
         path: '',
         redirectTo: '/tabs/tab1',