Diskussionsthread zur Schulung #1
Replies: 39 comments
-
<div class="container">
<h1>
<img
width="100"
alt="Angular Logo"
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADUCAMAAADukpxMAAAC5VBMVEUAAADXIcDlF4rTE57fJsHDCp/tJq3oLc+aHfOaG/DLLPHDKO7PGbTsH4mfIPbyCkyeIfrME6fdJcH2CEayIefxJZbeB3bzI3/4LqzoCV2+Ju34BED4CEP4MsPzJYX3A0T0Jo32Akf1KJr4BUH0KJ/yEFr0LLLyAU/0AUv1LretJvv5McD2L7z1Ck6qJfujI/q1Jvb0K6yxJvqfIfj4L7P0KqjzEFL2C0b1KJf1J5T0C1PzBVP0KaT1DUj1Mcv3LayuJfe5J/T1Mcb0D072Ckv3B0f4MsfyLb32Kp3KLPOZHfP0LK/0JYm4KPecIPeZG+31L8H4MLjzJICnJPvzC1f0D0vDKvTOLfLGK/TzMc/2BEryInjtAVjxBVf1BU21JfKxJfatI/S+KPHxMtenI/ejIfb4MLu9KfX3M8/zEFbwAVKVHfeeHvPyLLfzI33xC1vCKfH5Mb2VGu+kHu33LKXMB4/vBVvyLsL4Lq/3K6HcBXe0J/mqJPfHKvCwI+71M9bvAVWKGPXLK/CfHe7xMMzyL8j3LKjrAVylIfOxJPL2M9PiHaDoAWCZH/iPGvXSLvKhH/LFKe6fG+rvM9/xM9vPBoryIXTtCGPtBl/AKvW1JO7aJMXcGaGRGfGtIvCpHunxMdPcHazdF5vWBX/gA2/wCl+7JvDBJ+2qIOy4JOrmGI27KffcJMHZIbvHCJfhFpGpIvSoIfCuIOneHKbSFqb0JZDlAWT5L7XjHJz1J5G4JfD0NNrbH7TVFqLYFp3iAmn4MsvXHbTgIKzYGafeFpbSBYTpBGTuNOLUHrrfIbPXG63ECJvKB5OVHPPmGpLYBHvyIG2yIeryNN7eIrrdA3ONGPK+JuykHenPFau7JezjBnHbJsrQGbHiH6bbCH3TGa3rBGHiGZbSB4jkBGzoGYvWB4PgB3XnB2znBGi1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beta Was this translation helpful? Give feedback.
-
TypeScript: useDefineForClassFields – zukünftige Breaking Changes vermeidehttps://angular-buch.com/blog/2022-11-use-define-for-class-fields --> TODO fürs Wochenende |
Beta Was this translation helpful? Give feedback.
-
ng g c books/dashboard |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
<div class="card mb-4">
<div class="card-body bg-light">
<img class="img-thumbnail float-end" alt="" src="https://api.angular.schule/avatar/{{ book().rating }}">
<div class="card-title">
<h2>
{{ book().title }}
<span class="badge bg-secondary">{{ book().rating }}</span>
</h2>
</div>
<p>{{ book().description }}</p>
</div>
</div> |
Beta Was this translation helpful? Give feedback.
-
Gruppenarbeit1.) Gesamtzahl der Bücher ausgeben |
Beta Was this translation helpful? Give feedback.
-
getBookCount(): number {
return this.books().length;
}
getBookCount2 = computed(()=>this.books().length) |
Beta Was this translation helpful? Give feedback.
-
Mit ng-aquila: <nx-rating
[value]="book().rating"
startLabel="poor"
endLabel="great"
[ariaRatingLabels]="['1 of 5 Poor', '2 of 5', '3 of 5', '4 of 5', '5 of 5 Great']"
ariaRatingGroupLabel="Book rating"
></nx-rating |
Beta Was this translation helpful? Give feedback.
-
@for (iteration of stars(); track $index) { ⭐ } stars = computed(()=> new Array(this.book().rating)) |
Beta Was this translation helpful? Give feedback.
-
{{ ['Not rated yet', '⭐', '⭐⭐', '⭐⭐⭐', '⭐⭐⭐⭐', '⭐⭐⭐⭐⭐'][book().rating] }} |
Beta Was this translation helpful? Give feedback.
-
{{'⭐'.repeat(book().rating)}} |
Beta Was this translation helpful? Give feedback.
-
Eine Kleine Auswahl an Componenten-Libraries:
|
Beta Was this translation helpful? Give feedback.
-
import { ReactiveFormsModule } from '@angular/forms';
@Component({
// ...
imports: [ReactiveFormsModule]
})
export class BookCreateComponent { } |
Beta Was this translation helpful? Give feedback.
-
import { Component } from '@angular/core';
import { FormControl, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
@Component({
selector: 'app-book-create',
imports: [ReactiveFormsModule],
templateUrl: './book-create.component.html',
styleUrl: './book-create.component.scss'
})
export class BookCreateComponent {
bookForm = new FormGroup({
isbn: new FormControl('', {
nonNullable: true,
validators: [Validators.required, Validators.minLength(3)]
}),
title: new FormControl('', {
nonNullable: true,
validators: [Validators.required]
}),
description: new FormControl('', {
nonNullable: true
})
});
}
<form>
<div class="form-group">
<label for="isbn">ISBN</label>
<input type="text" class="form-control" id="isbn">
@if (false) {
<div class="feedback-error">Die ISBN ist ungültig!</div>
}
</div>
<div class="form-group">
<label for="title">Titel</label>
<input type="text" class="form-control" id="title">
</div>
<div class="form-group">
<label for="description">Beschreibung</label>
<textarea class="form-control" id="description"></textarea>
</div>
<button
type="submit" class="btn btn-primary mb-4">Erstellen</button>
</form> |
Beta Was this translation helpful? Give feedback.
-
Cross-cutting concern |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
import { provideHttpClient } from '@angular/common/http';
// app.config.ts
export const appConfig: ApplicationConfig = {
providers: [
provideHttpClient()
]
}; |
Beta Was this translation helpful? Give feedback.
-
import { HttpClient } from '@angular/common/http';
import { inject, Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { Book } from './book';
@Injectable({
providedIn: 'root'
})
export class BookStoreService {
http = inject(HttpClient);
getAllBooks(): Observable<Book[]> {
return this.http.get<Book[]>('https://api.angular.schule/books');
}
getSingleBook(isbn: string): Observable<Book> {
return this.http.get<Book>('https://api.angular.schule/books/' + isbn);
}
} |
Beta Was this translation helpful? Give feedback.
-
Hands On
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Hosting für 0 Euro Backend Frontend DNS DB |
Beta Was this translation helpful? Give feedback.
-
@use '@angular-schule/workshop-styles/index' with (
$primary: #8514F5,
$enable-rounded: false
); |
Beta Was this translation helpful? Give feedback.
-
https://rxmarbles.com/ |
Beta Was this translation helpful? Give feedback.
-
import { HttpErrorResponse } from '@angular/common/http';
import { Component, inject } from '@angular/core';
import { toSignal } from '@angular/core/rxjs-interop';
import { ActivatedRoute, RouterLink } from '@angular/router';
import { catchError, map, of, switchMap } from 'rxjs';
import { BookStoreService } from '../shared/book-store.service';
@Component({
selector: 'app-book-details',
imports: [RouterLink],
templateUrl: './book-details.component.html',
styleUrl: './book-details.component.scss'
})
export class BookDetailsComponent {
route = inject(ActivatedRoute);
bs = inject(BookStoreService);
book$ = toSignal(this.route.paramMap.pipe(
map(paramMap => paramMap.get('isbn') || ''),
switchMap(isbn => this.bs.getSingleBook(isbn).pipe(
catchError((err: HttpErrorResponse) => of({
title: 'Fehler',
description: err.message
}))
))
));
} @let b = book$();
@if (b) {
<h2>{{ b.title }}</h2>
<p>{{ b.description }}</p>
}
<a routerLink="/books/9783864909467">Gehe zu Angular</a><br>
<a routerLink="/books/9783864905520">Gehe zu React</a><br>
<a routerLink="/books/404">Gehe zu Fehler</a><br> |
Beta Was this translation helpful? Give feedback.
-
Herzlich Willkommen! 🎉 Hier können wir während der Schulung Links und Codeschnipsel teilen.
Beta Was this translation helpful? Give feedback.
All reactions