Skip to content

Ex2 solution#2

Open
luisa-beerboom wants to merge 2 commits into
GabrielInTheWorld:mainfrom
luisa-beerboom:ex2-solution
Open

Ex2 solution#2
luisa-beerboom wants to merge 2 commits into
GabrielInTheWorld:mainfrom
luisa-beerboom:ex2-solution

Conversation

@luisa-beerboom

Copy link
Copy Markdown
Collaborator

I did it!

@GabrielInTheWorld GabrielInTheWorld left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

In general, the code looks good!

There is still something to do.

});
}

public ngOnInit(): void {}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Remove unused functions

<input id="firstName" formControlName="firstName" type="text" placeholder="First Name..." autofocus>
<input id="lastName" formControlName="lastName" type="text" placeholder="Last Name...">

<button type="submit" class="smolButton addUser" [disabled]="addForm.value.title==='' || addForm.value.firstName==='' || addForm.value.lastName===''">+ Add User</button>

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Write logic in the .ts-file

Comment on lines +35 to +40
if(this.addForm.value.title==null){
this.messageService.add(`${this.addForm.value.firstName} ${this.addForm.value.lastName}`);
}
else{
this.messageService.add(`${this.addForm.value.title} ${this.addForm.value.firstName} ${this.addForm.value.lastName}`);
}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

You can simplify the message to only extend the "base" message by a title, if a title is provided.

Comment on lines +9 to +13
{ path: 'userlist', component: UserlistComponent },
{ path: 'edit', component: EditviewComponent },
{ path: 'dashboard', component: DashboardComponent },
{ path: 'detail/:id', component: UserDetailComponent },
{ path: '', redirectTo: '/dashboard', pathMatch: 'full' }

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Every route should point to a lazy loaded module

{ path: 'userlist', component: UserlistComponent },
{ path: 'edit', component: EditviewComponent },
{ path: 'dashboard', component: DashboardComponent },
{ path: 'detail/:id', component: UserDetailComponent },

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Try to write for every url segment an own path

Comment on lines +28 to +31
// getUsers(): void {
// this.userService.getUsers()
// .subscribe(users => this.users = users);
// }

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Remove

})
export class UserlistComponent implements OnInit {

users: BehaviorSubject<Map<number, User>> = new BehaviorSubject(new Map());

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Visibility modifier

@@ -0,0 +1,33 @@
import { Component, OnInit } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
//import { Title } from '@angular/platform-browser';

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Remove

Comment on lines +9 to +12
{ path: 'userlist', component: UserlistComponent },
{ path: 'edit', component: EditviewComponent },
{ path: 'dashboard', component: DashboardComponent },
{ path: 'detail/:id', component: UserDetailComponent },

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Besides: You point with every route (except the dashboard) to a user-concerning component. Therefore, create at least a user-module and write something like this:

Suggested change
{ path: 'userlist', component: UserlistComponent },
{ path: 'edit', component: EditviewComponent },
{ path: 'dashboard', component: DashboardComponent },
{ path: 'detail/:id', component: UserDetailComponent },
{ path: '', component: UserlistComponent },
{ path: 'edit/:id', component: EditviewComponent },
{ path: 'detail/:id', component: UserDetailComponent },

templateUrl: './editview.component.html',
styleUrls: ['./editview.component.scss']
})
export class EditviewComponent implements OnInit {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

In general: Name components related to their concerns. For example: UserEditViewComponent.

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.

2 participants