Java, .NET, PHP, PYTHON, ANGULAR, .NET, ML, Data Scince, Testing, CI Tutorials in Easy Languages.

"Best Software Training, Internship, Project Development center of Indore India, Helpline 780506-3968"

Create Template Driven Forms in Angular:-

1st:-   Create Component using ng g c scs
2nd:-  Create FormDesign Similar to HTML Form

<form  method="post" (ngSubmit)="display()"  #fs="ngForm">
Enter name
<input type="text" name="txt"  [(ngModel)]="txt" />
<input type="submit" name="btnsubmit" value="submit" />

here ngSubmit is used for a button click ,ngModel is used to bind HTML element text to the controller object.

Write Code to display TextField Data under TypeScript code using Component Class
export class RaheemComponent implements OnInit {
  constructor() {''


  ngOnInit() {
    alert(this.txt); this.txt;


4th:-  When you run this code then it will appear error because FormModule Should be import under appmodule.ts without this we can not access data from HTML Template to Component.

import {  FormsModule } from '@angular/forms';  

 imports: [

Post a Comment

If you have any doubt in programming or join online classes then you can contact us by comment .

Previous Post Next Post