Тёмный
No video :(

Edit form in angular 

kudvenkat
Подписаться 832 тыс.
Просмотров 92 тыс.
50% 1

In this video we will discuss editing and updating data in Angular. To set the expectations right, we will be updating data on the client side. We will discuss persisting the data to a database table in our upcoming videos when we implement the server side service.
Healthy diet is very important for both body and mind. We want to inspire you to cook and eat healthy. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking.
/ @aarvikitchen5572
We are going to modify "Create Employee Form" so it supports both
1. Creating a new employee
2. Editing and updating an existing employee
Text version of the video
csharp-video-tu...
Slides
csharp-video-tu...
Angular CRUD Tutorial
• Angular CRUD tutorial
Angular CRUD Tutorial Text Articles & Slides
csharp-video-tu...
All Dot Net and SQL Server Tutorials in English
www.youtube.co...
All Dot Net and SQL Server Tutorials in Arabic
/ kudvenkatarabic

Опубликовано:

 

27 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 30   
@mohammedk.k6472
@mohammedk.k6472 6 лет назад
welcome back Professor Venkat, I always pray for you.Allah bless you
@nolancoen8925
@nolancoen8925 3 года назад
A tip: you can watch movies on InstaFlixxer. Been using them for watching all kinds of movies these days.
@houstonkorbin550
@houstonkorbin550 3 года назад
@Nolan Coen Definitely, I have been watching on instaflixxer for months myself :)
@kanejad6389
@kanejad6389 3 года назад
@Nolan Coen yup, been watching on InstaFlixxer for since november myself :)
@rickyjohnny8452
@rickyjohnny8452 3 года назад
@Nolan Coen yea, have been watching on instaflixxer for since november myself =)
@gaelalessandro959
@gaelalessandro959 3 года назад
@Nolan Coen yea, I have been watching on instaflixxer for since november myself =)
@rimasawant8181
@rimasawant8181 6 лет назад
This channel is best of all!! @Venkat Sir : Requesting you to please do some videos for HTML5 and CSS3 as they are must know skills now a days everywhere as a full stack developer. Thanks
@AZHARKHAN-fw5mv
@AZHARKHAN-fw5mv 6 лет назад
Good job sir,you are great teacher in the world
@wilsonsfiso3310
@wilsonsfiso3310 5 лет назад
much love from South Africa
@funfilm5156
@funfilm5156 5 лет назад
You are the best sir....
@ThePavle998
@ThePavle998 4 года назад
A very good teacher!
@ThePavle998
@ThePavle998 4 года назад
export class BooksService { books: Array; constructor(private http: HttpClient) { } show(title: string, text: string) { alert(text); } get(): Observable { return this.http.get('fakerestapi.azurewebsites.net/api/books'); export class BooksComponent implements OnInit { books: Array; constructor(private bService: BooksService) { } ngOnInit() { this.getBooks(); } getBooks() { this.bService.get().subscribe((data) => {this.books = data; }); } }
@gregorslana7723
@gregorslana7723 6 лет назад
Hello, i am using APIs to retrieve data, and when i get to edit mode of an employee, i get invalid date in the input field of date?
@ymtan
@ymtan 6 лет назад
Dear Venkat, I find it very difficult to understand the following block of code in the save() method in employee.service.ts. save(employee: Employee) { if (employee.id === null) { const maxId = this.listEmployees.reduce(function (e1, e2) { return (e1.id > e2.id) ? e1 : e2; }).id; employee.id = maxId + 1; this.listEmployees.push(employee); } else { const foundIndex = this.listEmployees.findIndex(e => e.id === employee.id); this.listEmployees[foundIndex] = employee; } } The first question is regarding the reduce() method. I don't understand what do you mean the reduce() method reduces the array to a single value ? The second and most important question is regarding the reduce() method. Could you kindly explain the logic on how to reduce the listEmployees array into a single value especially on how the provided function is executed for every employee object in the listEmployees array from left-to-right ? The final question is regarding the two lines of code within the else block as shown below. const foundIndex = this.listEmployees.findIndex(e => e.id === employee.id); this.listEmployees[foundIndex] = employee; I don't understand why do we need to replace the existing employee object at the found index with the incoming employee object ? Best regards, Edward
@Csharp-video-tutorialsBlogspot
The first question is regarding the reduce() method. I don't understand what do you mean the reduce() method reduces the array to a single value ? The final question is could you kindly explain the logic on how to reduce the listEmployees array into a single value because I don't understand how it works ? The following is the answer for both the above questions : When employee id is null, it implies that we are creating a new employee. When a new employee is created, we need to compute the id property value, before we push that employee object into the array. So to compute the next id value, we first need to identify what is the current maximum id value in the listEmployees array. There are several ways to do this. One way is by using the reduce() JavaScript method. We need to tell the reduce() method on how to compare 2 employee objects to find the object that has the greater id value. So we are passing an anonymous function as a parameter to the reduce() method. This anonymous function(e1, e2), has 2 employee objects and the logic on how to compare these 2 objects and return the object which has greater id value. The reduce() method will then apply this logic to all the elements in the listEmployees array from left to right. So finally when the the reduce method completes execution it will be left with one employee object. This object is the one that has the maximum id value. We then add 1 to that max id value and assign the resulting value to the id property of the employee object that is being pushed into the listEmployees array. The second question is regarding the two lines of code inside the else block. I don't understand why do we need to replace the existing employee object at the found index with the incoming employee object ? As you might already know, else block is executed if id property value of the incoming employee object is not null. This means we have edited an employee object and those details need to be saved. Instead of copying each property value of the incoming employee object into the original employee object in the listEmployees array, we are replacing the existing original object with the incoming object. To do that we first find the original employee object index position in the listEmployees array using findIndex() method. We then use that index position to replace the original employee object in the listEmployees array with the incoming updated employee object.
@ymtan
@ymtan 6 лет назад
Thank you very much for your reply. Could you kindly explain the logic on how to compare the 2 employee objects (e1 and e2) and return the object which has greater id value. How the reduce() method will then apply this logic to every element in the listEmployees array from left to right ? In our case, we have three employee objects in the listEmployees array. So is e1 refer to employee Mark and e2 refer to employee Mary ?
@Csharp-video-tutorialsBlogspot
Basically we are telling to compare the id property of 2 employee objects and then return the employee object which has the greater id value of those 2 employee objects. So the reduce() will now apply this logic to the first 2 employee objects (Mark and Mary). Mary employee object id value is greater than Mark employee object. So Mary object will then be compared with John employee object. John employee object has greater id value than Mary employee object, so John employee object will finally be returned. In our case we only have 3 employees in the array. Even if you have more than 3 elements in the array, the comparison logic is applied in a similar fashion from left to right and finally returns that one object which has the maximum id value. Hope this clarifies.
@ymtan
@ymtan 6 лет назад
Dear Venkat, Regarding the following code, you have mentioned that the employee object is automatically updated because the employee property is holding a reference to the employee object in the EmployeeService. this.employee = this._employeeService.getEmployee(id); Could you kindly please explain what do you mean the employee property is holding a reference to the employee object in the EmployeeService because I don't understand ? May I ask what is a reference ?
@Csharp-video-tutorialsBlogspot
This is a basic programming concept. Objects are different from object reference variables. An object reference variable is not an object, rather it's a pointer to an object. It's possible, you may have 2 object reference variables but they may be pointing at the same object. In this case, that's exactly what's happening. this.employee property is a reference variable and pointing at the same object in the array in EmployeeService. Hope this clarifies. If the concept of Objects and Object reference variables is still confusing, I suggest watch the following 2 videos and also read the respective text articles. Why should you override Equals() method ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-IhXWil0kcTo.html Text Article csharp-video-tutorials.blogspot.com/2012/07/part-58-c-tutorial-why-should-you.html Angular Pure Pipe ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-G7WaP-yoiQg.html Text Article csharp-video-tutorials.blogspot.com/2018/05/angular-pure-pipe.html
@sr.rysage5066
@sr.rysage5066 6 лет назад
Thank you for all your great tutorial series. I really appreciated the course structures, clear explanations and rich project examples. Would you have some development project tutorial about Angular Flex-Layout or Material as well? Thanks again & all the best Rysage
@johniliya4060
@johniliya4060 6 лет назад
Good evening sir..love your videos sir.. Sir please can you create a video on creating a facebook type comment system in angularjs ,c# and sqlserver
@maciek77killer
@maciek77killer 5 лет назад
Why edit employee is success before you add new save method implementation (check if id is null or exist in db)?
@CCPony
@CCPony 3 года назад
Venkat for President!
@mshubhamtyagi9166
@mshubhamtyagi9166 6 лет назад
I am using the same form for adding and updating the details but in my case, the parent is a module and child is the component name as userdetails & adduserdetails . In the parent, I have a table for displaying details. At the end of every data row, I have an action button through which I am sending this data row to the child component form for editing the details. But I have no idea how I change the form title when I am going to editing the user details. Please guide me.
@joy5872
@joy5872 6 лет назад
how to fill data in text box and select tag when edit data
@CodeWithJamil786
@CodeWithJamil786 4 года назад
sir how can i edit and update the image using angular and php
@Albertmars32
@Albertmars32 6 лет назад
can you do a series on advance Reactjs and firebase together?
Далее
Angular delete form
18:51
Просмотров 27 тыс.
Angular reactive forms edit example
12:59
Просмотров 63 тыс.
ЛОВИМ НОВЫХ МОНСТРОВ В LETHAL COMPANY
2:42:22
C’est qui le plus fort 😂
00:18
Просмотров 9 млн
Liskov: The Liskov Substitution Principle
4:23
Просмотров 21 тыс.
Angular content projection
15:38
Просмотров 36 тыс.
Create observable from array
11:40
Просмотров 34 тыс.
Angular accordion example
9:57
Просмотров 43 тыс.