This commit is contained in:
trochas
2024-10-21 16:19:13 +02:00
commit e503d598ad
31 changed files with 15272 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
const routes: Routes = [];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }

View File

View File

@@ -0,0 +1,6 @@
<div style="text-align:center">
<h1>
{{ title }}!
</h1>
</div>
<app-my-component></app-my-component>

View File

@@ -0,0 +1,35 @@
import { TestBed } from '@angular/core/testing';
import { RouterModule } from '@angular/router';
import { AppComponent } from './app.component';
describe('AppComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [
RouterModule.forRoot([])
],
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 'pokedemo'`, () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.componentInstance;
expect(app.title).toEqual('pokedemo');
});
it('should render title', () => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.nativeElement as HTMLElement;
expect(compiled.querySelector('h1')?.textContent).toContain('Hello, pokedemo');
});
});

11
src/app/app.component.ts Normal file
View File

@@ -0,0 +1,11 @@
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrl: './app.component.css'
})
export class AppComponent {
title = 'pokedemo';
}

25
src/app/app.module.ts Normal file
View File

@@ -0,0 +1,25 @@
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { MyComponentComponent } from './my-component/my-component.component';
import { FilterPokemonPipePipe } from './filter-pokemon--pipe.pipe';
@NgModule({
declarations: [
AppComponent,
MyComponentComponent,
FilterPokemonPipePipe
],
imports: [
BrowserModule,
FormsModule,
AppRoutingModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }

View File

@@ -0,0 +1,8 @@
import { FilterPokemonPipePipe } from './filter-pokemon--pipe.pipe';
describe('FilterPokemonPipePipe', () => {
it('create an instance', () => {
const pipe = new FilterPokemonPipePipe();
expect(pipe).toBeTruthy();
});
});

View File

@@ -0,0 +1,12 @@
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'filterPokemonPipe'
})
export class FilterPokemonPipePipe implements PipeTransform {
transform(value: unknown, ...args: unknown[]): unknown {
return null;
}
}

View File

@@ -0,0 +1,14 @@
<input [(ngModel)]="id">
<input readonly [(ngModel)]="id">
<BR>
id : {{id}}
<select [(ngModel)]="selectedPokeId">
<option [value]="poke.id" *ngFor="let poke of pokes"> {{poke.name}}</option>
</select>
<ul>
<li *ngFor="let poke of pokes; index as i">{{poke.name}}</li>
</ul>

View File

@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { MyComponentComponent } from './my-component.component';
describe('MyComponentComponent', () => {
let component: MyComponentComponent;
let fixture: ComponentFixture<MyComponentComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [MyComponentComponent]
})
.compileComponents();
fixture = TestBed.createComponent(MyComponentComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -0,0 +1,29 @@
import { Component } from '@angular/core';
//import { constructor } from 'jasmine';
import { Pokemon } from '../pokemon';
@Component({
selector: 'app-my-component',
templateUrl: './my-component.component.html',
styleUrl: './my-component.component.css'
})
export class MyComponentComponent {
id: string;
selectedPokeId : string;
pokes : Pokemon[] = [];
constructor(){
this.pokes.push(new Pokemon('2', "Herbizarre"));
this.pokes.push(new Pokemon('3', "Florizarre"));
this.pokes.push(new Pokemon('4', "Salamèche"));
this.pokes.push(new Pokemon('5', "Reptincel"));
this.pokes.push(new Pokemon('6', "Dracaufeu"));
this.pokes.push(new Pokemon('7', "Carapute"));
this.pokes.push(new Pokemon('8', "Carabaffe"));
this.pokes.push(new Pokemon('9', "Tortank"));
}
ngOnInit(): void {
}
}

7
src/app/pokemon.spec.ts Normal file
View File

@@ -0,0 +1,7 @@
import { Pokemon } from './pokemon';
describe('Pokemon', () => {
it('should create an instance', () => {
//expect(new Pokemon("1","test")).toBeTruthy();
});
});

7
src/app/pokemon.ts Normal file
View File

@@ -0,0 +1,7 @@
export class Pokemon {
constructor(public id:string, public name:string){
}
}

13
src/index.html Normal file
View File

@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Pokedemo</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<app-root></app-root>
</body>
</html>

10
src/main.ts Normal file
View File

@@ -0,0 +1,10 @@
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
platformBrowserDynamic().bootstrapModule(AppModule, {
ngZoneEventCoalescing: true
})
.catch(err => console.error(err));

1
src/styles.css Normal file
View File

@@ -0,0 +1 @@
/* You can add global styles to this file, and also import other style files */