Тёмный
No video :(

Angular forms tutorial 

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

In Part 2 of Angular CRUD tutorial, we discussed performing the READ operation. In this video and in the next few videos we will discuss performing the CREATE operation. To understand the CREATE operation, let us build a form that help us create a new employee. For this we will use the createEmployee component that we already created in one of our previous videos in this series.
Along the way, we will also discuss performing validation and displaying meaningful error messages to the user.
Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our RU-vid channel. Hope you can help.
/ @aarvikitchen5572
There are 2 ways to create forms in Angular
1. Template Driven Forms
2. Model Driven Forms (Commonly called Reactive Forms)
Both these approaches have their own pros and cons. For example, Template Driven forms are generally used to create simple forms. On the other hand, Reactive forms are used to create complex forms. For example, if you want to add form controls dynamically or perform cross-field validation we use the Reactive forms approach. There are several other differences, between Template driven and Reactive forms. We will discuss those differences in detail, in a later video.
In this video, we will use the Template driven approach to build the "Create Employee" form. As the name implies, template driven forms are heavy on the template. This means we do most of the work in the view template of the component.
Design "Create Employee" form. To keep this simple, at the moment we only have 2 fields (Full Name & Email). We will add the other fields like Gender, Department, Phone Number etc.. later. Also, at the moment, we only have textboxes on our form. In our upcoming videos we will discuss working with radio buttons, checkbox, dropdownlist etc
For the form HTML, please refer to our blog using the below link.
csharp-video-tu...
Code Explanation:
We are using Bootstrap CSS classes like panel, panel-primary, panel-heading, panel-title etc to style the form. There is no Angular here. If you are new to bootstrap, please click here to check out our Bootstrap tutorial using the following link
csharp-video-tu...
Consider the following line of code
[form #employeeForm="ngForm" (ngSubmit)="saveEmployee(employeeForm)"]
#employeeForm is called the template reference variable. Notice we have assigned "ngForm" as the value for the template reference variable employeeForm. So employeeForm variable holds a reference to the form. When Angular sees a form tag, it automatically attaches the ngForm directive to it. The ngForm directive supplements the form element with additional features. It holds all the form controls that we create with ngModel directive and name attribute, and monitors their properties like value, dirty, touched, valid etc. The form also has all these properties. We will discuss these properties at the individual control level and at the form level in detail in our upcoming videos.
The ngSubmit directive submits the form when we hit the enter key or when we click the Submit button. When the form is submitted, saveEmployee() method is called and we are passing it the employeeForm. We do not have this method yet. We will create it in the component class in just a bit.
The ngForm directive is provided by Angular FormsModule. So for us to be able to use it, we will have to import the FormsModule in our AppModule file (app.module.ts). So please make sure to include the following import statement. Also include "FormsModule" in the imports array of @NgModule decorator.
import { FormsModule } from '@angular/forms';
The ngModel directive is used for creating two-way data binding i.e to keep the HTML element value and it's corresponding component property in sync. We discussed two-way data binding in detail in our Angular 2 course. Use the link below to watch two-way data binding video.
• Two way data binding i...
Text version of the video
csharp-video-tu...
Slides
csharp-video-tu...
Angular CRUD Tutorial
• What is Angular CLI
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

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 68   
@ahmedalshora
@ahmedalshora 3 года назад
for errors simply use ngModel only like
@Anas-gh3ie
@Anas-gh3ie Год назад
Absolutely useful
@DecentProgrammer
@DecentProgrammer Год назад
Best tutorial for angular in the internet :)
@jenithjana5178
@jenithjana5178 4 года назад
if you get this error Property 'fullName' does not exist on type 'CreateEmployeeComponent' Property 'email' does not exist on type 'CreateEmployeeComponent' then include these two property in CreateEmployeeComponent fullName: string; email:string;
@SumanDas-df5df
@SumanDas-df5df Год назад
export class CreateEmployeeComponent implements OnInit { fullName:string; email:string; ... ..... ....} Need to add above 2 lines in "create-employee.component.ts file"
@ibrahimMarzaq
@ibrahimMarzaq 5 лет назад
Interesting. Easy. Clear. detailed. Thank you very much.
@nys8260
@nys8260 3 года назад
you are the best
@samadhansalgar9181
@samadhansalgar9181 3 года назад
No words to appriciate sir, Thanks loooooooooooooooooooooooooooot for wonderfull videos
@someshravi4377
@someshravi4377 6 лет назад
best video tutorials ever watched.thanks....
@AbhishekPandey-gw9xx
@AbhishekPandey-gw9xx 5 лет назад
best tutorial .u have explained it very well.indeed angular crud has been explained by u in detail nd very well. thank u
@Csharp-video-tutorialsBlogspot
Hello Abhishek - Thank you. Means a lot. Very glad you are finding our angular courses useful.
@saurabhchauhan232
@saurabhchauhan232 6 лет назад
Please add one file upload control as well so it can be much helpful sir.
@srujankumarl
@srujankumarl 6 лет назад
This is too good. You are the best!
@LittleRainGames
@LittleRainGames 6 лет назад
You sir are an amazing teacher.
@ievgengolskov1611
@ievgengolskov1611 6 лет назад
Webstorm shows me mistake on [(ngModel)]="fullName" and demands to add property fullName to component.ts. but in your code it looks like everything is fine. can't figure out why is it so
@satvik7474
@satvik7474 6 лет назад
haha dont know man. just add property in .ts and let it happen xP
@atolimbi1
@atolimbi1 6 лет назад
as far as I know, you could use [(ngModel)] to pre-fill with some info the inputs on your form, so, for example, you could use a service to obtain the full name save it on the property full name of your component and then the field will be populated with the current full name in your form
@nessd1
@nessd1 6 лет назад
You can do this: [ngModel]="" Maybe is the CLI version. I have the same issue
@pulagamsunilreddy1022
@pulagamsunilreddy1022 4 года назад
I added the properties in .ts file and the compilation is successful. Wonder why the error did not occur in the video. I am using Angular ver8.
@naodagere8210
@naodagere8210 4 года назад
Great. Thank you so much.
@MmMm-tg5mq
@MmMm-tg5mq 5 лет назад
very nice thanks
@sheetalaware7135
@sheetalaware7135 6 лет назад
Really Helpful
@HassanKhan-ge8ik
@HassanKhan-ge8ik 6 лет назад
Great tutorial Venkat Sir. In the video you talked by reactiveforms but i cant find any video on reactiveforms in your list. Please add. Thanks in advance !
@rhonwenvandruten820
@rhonwenvandruten820 5 лет назад
ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-VLYc3ACWL-E.html
@SweetMemories368
@SweetMemories368 4 года назад
Without declaring a property in component, two-way binding is not working in angular 9, giving error r as property 'fullName' not exist in component. Thanks in advance
@9461910195
@9461910195 4 года назад
have you found solution to this problem ? I am also facing the same issue.
@SumanDas-df5df
@SumanDas-df5df Год назад
export class CreateEmployeeComponent implements OnInit { fullName:string; email:string; ... ..... ....} Need to add above 2 lines in "create-employee.component.ts file"
@belmiris1371
@belmiris1371 6 лет назад
Thank you for this video
@juturisharon3075
@juturisharon3075 6 лет назад
Awesome
@arunisk1775
@arunisk1775 6 лет назад
Hi sir, Can you please provide videos for reactive form.
@noorulhaq1620
@noorulhaq1620 6 лет назад
unique
@MotionInMotion1975
@MotionInMotion1975 4 года назад
Hello Kudvenkat. Your videos are invaluable. Thanks so much. Im having an issue displaying for form value. I always get [object Object]. Any idea of what may be wrong?Thanks.
@LogaThrimDev
@LogaThrimDev 4 года назад
Thanks
@sourishdutta9600
@sourishdutta9600 6 лет назад
what is the difference between @viewchild vs @viewchildren and why we need this and full concept about observable and how it helps to make code asynchronous ?! Thank you sir.Please discuss to this topics sir.😊
@shashikantshukla107
@shashikantshukla107 4 года назад
Hi I am new to it. i am getting error 15 ~~~~~~ src/app/Employee/create-employees.component.ts:7:16 7 templateUrl: './create-employees.component.html', ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Error occurs in the template of component CreateEmployeesComponent. I copied exactly same as in video
@ChandanKumar-ik8pf
@ChandanKumar-ik8pf 6 лет назад
why intelinsense is not working with bootsrap class name in this video?
@gvsprakashrao5866
@gvsprakashrao5866 3 года назад
Hello Sir, I am getting the error below though I am using the same code as you instructed in the video and blog. (This likely means that the library (@angular/forms) which declares FormGroup has not been processed correctly by ngcc, or is not compatible with Angular Ivy.) Do you have any solution for this. I tried adding reactive forms module, but it has created another problem, it then says router outlet is an angular component, then verify that it is part of this module...please suggest I am currently using angular 10 and I am having lot of problems which I am not able to solve and I havent progressed beyond video 20 of your tutorial
@umairhafeez3462
@umairhafeez3462 6 лет назад
hi i am a beginner on angular and i found difficult... so, can you please guide me, from where should I start angular!
@prudvid8894
@prudvid8894 5 лет назад
first html,css,bootstrap and javascript basics....later on angluar 2 tutorials for beginners (kudvenkat)and after that crud operations(KudVenkat) .
@santoshkumar-vm
@santoshkumar-vm 6 лет назад
Hello sir. Thanku for nice tutorial. Sir please can you provide reactive form tutorial with all the fields in this form. Plz provide any tutorial on reactive form.thanks in advance.
@sippiarora9844
@sippiarora9844 3 года назад
How to initialize property in the constructor component?
@anthonymouso9156
@anthonymouso9156 3 года назад
hello when i write [(ngModel)]="email" he gives me this error src/app/create/create.component.html:26:24 - error TS2339: Property 'email' does not exist on type 'CreateComponent'. 26 [(ngModel)]="email" wat is the problem ~~~~~
@ahmedalshora
@ahmedalshora 3 года назад
simply use
@KhurramShahzad-os5hj
@KhurramShahzad-os5hj 6 лет назад
sir please make video series on angular 2 with mvc
@VinothKumar5403
@VinothKumar5403 6 лет назад
Is possible to apply number pipe for formcontrolname?.if yes please help me ,how to achieve the same
@gvsprakashrao5866
@gvsprakashrao5866 3 года назад
when ever I add ngModel to any input element, its gives and error saying property 'fullName ' does not exist on type 'createEmploymentComponent'
@rajeshbisht4675
@rajeshbisht4675 3 года назад
coz you have to create property for both fullname and email in your ts file
@damandeepsingh2460
@damandeepsingh2460 6 лет назад
How to create multistep form using single component ?
@mrmishra8241
@mrmishra8241 6 лет назад
Can we design and perfom submit operation in Angular 5.0 without form tag Really need to know please Help...
@Asivakumar503
@Asivakumar503 6 лет назад
hai venkat. please make a video on PWS offline service in angular5. so many interviewrs asking that.
@kiran59345
@kiran59345 4 года назад
error: Property 'name' does not exist on type 'CreateContactComponent'
@sachinhd517
@sachinhd517 5 лет назад
Identifier 'email' is not defined. The component declaration, template variable declarations, and element references do not contain such a memberAngular
@9461910195
@9461910195 4 года назад
facing the same issue , any luck on the solution ?
@satyass3588
@satyass3588 6 лет назад
When can we expect Angular 4 tutorial?
@Csharp-video-tutorialsBlogspot
Hi Satya - For all these videos in Angular CRUD tutorial playlist we are using Angular 5. There is no much difference between Angular 2, Angular 4 and Angular 5. The following video explains the differences ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-bAx2LgQLkl8.html Hope this helps. Please let me know if there are any other questions.
@satyass3588
@satyass3588 6 лет назад
Hi Venkat, If l go through your "Angular 2 tutorial for beginners" playlist, I can learn Angular 4 easily am i correct?
@satyass3588
@satyass3588 6 лет назад
kudvenkat ... thanks for your reply
@thirstycode
@thirstycode 6 лет назад
Kindly implement crud with asp core .and handle all html helpers
@attequrrehman6525
@attequrrehman6525 6 лет назад
Please make video on sending data with uploaded image and saving this data in database via api...
@attequrrehman6525
@attequrrehman6525 6 лет назад
Data means full name adress and also an image.... This may be stored in database using api
@kennethwright69
@kennethwright69 2 года назад
The info in this tutorial is outdated and will no longer work with the newer versions of angular!
@ihappy7777
@ihappy7777 4 года назад
Labad hara
@Surendrathota1
@Surendrathota1 6 лет назад
plz add video for reactiveforms
@Csharp-video-tutorialsBlogspot
Sure,we will cover reactive forms in our upcoming videos in this series. Please stay tuned.
@Surendrathota1
@Surendrathota1 6 лет назад
Thank you kudvenkat
@prakashgunjari1986
@prakashgunjari1986 3 года назад
Hello Sir I am getting this error property fullName does not exist on type 'createEmployeeComponent', The application runs the first time even with the errors , but if I restart the PC the application does not work and the errors are still there, is it something related to caching, if so how should I solve it
Далее
Bootstrap radio buttons in Angular
7:21
Просмотров 72 тыс.
Angular reactive forms
10:49
Просмотров 203 тыс.
what will you choose? #tiktok
00:14
Просмотров 2,4 млн
WILL IT BURST?
00:31
Просмотров 26 млн
Reading data in angular
16:49
Просмотров 162 тыс.
Angular form validation
11:41
Просмотров 143 тыс.
What’s new in Angular v18
20:08
Просмотров 118 тыс.
Model binding in angular template driven forms
10:06
Просмотров 52 тыс.
Angular routing and navigation
12:51
Просмотров 100 тыс.
Angular email validation example
12:00
Просмотров 65 тыс.
Angular base href
7:18
Просмотров 86 тыс.
Angular ngif directive
11:44
Просмотров 45 тыс.
React User Login and Authentication with Axios
31:37
Просмотров 556 тыс.