4 - Angular 2 and Spring Boot: What is forms module and how to use ngForm?
Автор: Almighty Java
Загружено: 2019-07-27
Просмотров: 547
Описание:
#Angular #SpringBoot #FormsModule #NgForm #NgModule #NgModel
=======================
OnInit
----------------
A lifecycle hook that is called after Angular has initialized all data-bound properties of a directive. Define an ngOnInit() method to handle any additional initialization tasks.
interface OnInit {
ngOnInit(): void
}
ngOnInit()
----------------
A callback method that is invoked immediately after the default change detector has checked the directive's data-bound properties for the first time, and before any of the view or content children have been checked. It is invoked only once when the directive is instantiated.
=======================
FormsModule
----------------
Exports the required providers and directives for template-driven forms, making them available for import by NgModules that import this module.
=======================
ngForm
----------------
Ex - #myTemplateVar="ngForm"
----------------
As soon as you import the FormsModule, this directive becomes active by default on all form tags. You don't need to add a special selector.
You optionally export the directive into a local template variable using ngForm as the key (ex: #myForm="ngForm"). This is optional, but useful. Many properties from the underlying FormGroup instance are duplicated on the directive itself, so a reference to it gives you access to the aggregate value and validity status of the form, as well as user interaction properties like dirty and touched.
To register child controls with the form, use NgModel with a name attribute. You may use NgModelGroup to create sub-groups within the form.
If necessary, listen to the directive's ngSubmit event to be notified when the user has triggered a form submission. The ngSubmit event emits the original form submission event.
In template driven forms, all form tags are automatically tagged as NgForm. To import the FormsModule but skip its usage in some forms, for example, to use native HTML5 validation, add the ngNoForm and the form tags won't create an NgForm directive. In reactive forms, using ngNoForm is unnecessary because the form tags are inert. In that case, you would refrain from using the formGroup directive.
Повторяем попытку...

Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: