Skip to content

Angular Training App - Pavel Trifonov #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 40 commits into
base: main
Choose a base branch
from

Conversation

tpavels
Copy link

@tpavels tpavels commented May 29, 2025

No description provided.

tpavels and others added 30 commits May 26, 2025 13:37
- Changed app title from 'angular-template' to 'Training Angular Project'.
- Introduced Post model interface for better type management.
- Enhanced posts-list component to display posts with detailed information.
- Created posts-page component to manage posts loading and error handling.
- Implemented NgRx state management for posts, including actions, effects, reducers, and selectors.
- Added PostsService for API interactions with JSONPlaceholder.
- Set up environment configuration for API URL.
- Updated main.ts to include NgRx store and effects providers.
- Integrated Angular Material components including MatToolbar, MatCard, and MatButton.
- Updated app.component.html to include a navigation toolbar.
- Refactored posts-list.component.html to use MatCard for displaying posts.
- Enhanced styles in app.component.scss and posts-list.component.scss for better layout.
- Updated package.json and package-lock.json to include Angular Material and CDK dependencies.
…ment; improve error handling and loading states in templates
… GuestbookPage components with templates and tests
@tpavels tpavels changed the title Angular Training App Angular Training App - Pavel Trifonov May 29, 2025
<mat-form-field appearance="fill">
<mat-label>Name</mat-label>
<input matInput formControlName="name" required>
<mat-error *ngIf="guestBookForm.get('name')?.hasError('required')">
Copy link

@up-ctc up-ctc May 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In modern angular you can inprove readability by using new @if / @for syntax -> https://angular.dev/essentials/templates#control-flow-with-if-and-for
in that case ngIf or Common module import is not needed as well.

@@ -1 +1,5 @@
/* You can add global styles to this file, and also import other style files */
@import "@angular/material/prebuilt-themes/indigo-pink.css";
Copy link

@up-ctc up-ctc May 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This most probably works, but should be deprecated. In Angular 19 syntax was changecd to @use. No need to change, just FYI.


constructor(
private guestPostEntryForm: FormBuilder,
private guestBookEntryDialogRef: MatDialogRef<GuestbookEditComponent>,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In new Angular services can be injected like
private guestPostEntryForm = inject(FormBuilder)

Here is nice article on diference of approaches -> https://alyshovtapdig.medium.com/inject-vs-constructor-in-angular-which-one-should-you-use-en-dbdf1070739c

{ id: 1, postId: 1, body: 'Test comment' } as Comment
];

service.getByPost(post).subscribe(comments => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't forget to unsubscribe from your "long-lived" subscriptions, otherwise you'll get nasty memory leaks

RouterLink,
MatCardModule,
MatButtonModule,
MatToolbarModule
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should only import specific components\directives\pipes rather than whole module. It will be better "tree-shaked" during build time which will save you some bytes on final build.

styleUrl: './posts-list.component.scss'
})
export class PostsListComponent {
@Input() posts: Post[] | null = [];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use a new input syntax as well, it will use signals and better integrate with overall signals approach

Copy link
Collaborator

@alexbaluhin alexbaluhin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants