Q:

Using controls with template-driven forms angular

I'm trying to use NGForm in angular but what I didn't understand is using ngForm controls
thanks
stackblitz: https://stackblitz.com/edit/angular-gt66nu
here is an example: 

app-component.html

<form name="form" #f="ngForm">

<div>
    <label>name</label>
    <input name="name" [(ngModel)]="model.name">
</div>
    <div>
        <label>surname</label>
        <input name="surname" [(ngModel)]="model.surname">  
    </div>

 </form>

app-component.ts

import { Component, AfterViewInit,ViewChild } from '@angular/core';
import {NgForm} from '@angular/forms'

@Component({
selector: 'my-app',
templateUrl: 'app.component.html'
})

export class AppComponent implements AfterViewInit {
model: any = {};
oldForm;
@ViewChild('f', {static: false}) form: NgForm
onSubmit() {
 alert('SUCCESS!! :-)\n\n' + JSON.stringify(this.model))
}

ngAfterViewInit() {
     this.oldForm = this.form.controls
     console.log('form: ',this.form);
     this.form.form.valueChanges.subscribe( item => {
       console.log('item: ' ,item);
     })
   }
 }

consol

A:

Have a look at Angular NgForm docs or check out Angular tutorials for Template-driven Forms.

NgForm: directive
Creates a top-level FormGroup instance and binds it to a form to track
  aggregate form value and validation status.

Easy example:
import {Component} from '@angular/core';
import {NgForm} from '@angular/forms';

@Component({
  selector: 'example-app',
  template: `
    <form #f="ngForm" (ngSubmit)="onSubmit(f)" novalidate>
      <input name="first" ngModel required #first="ngModel">
      <input name="last" ngModel>
      <button>Submit</button>
    </form>

    <p>First name value: {{ first.value }}</p>
    <p>First name valid: {{ first.valid }}</p>
    <p>Form value: {{ f.value | json }}</p>
    <p>Form valid: {{ f.valid }}</p>
  `,
})
export class SimpleFormComp {
  onSubmit(f: NgForm) {
    console.log(f.value);  // { first: '', last: '' }
    console.log(f.valid);  // false
  }
}

