Шаблонные формы. undefined Шаблонные формы.

Шаблонные формы.

Open in new window

<<<<<<< HEAD

Шаблонные формы.

class GoodComment {
      public author: string,
      public content: string,
    ) {  }


import { Component } from '@angular/core';

  selector: 'app-comment-form',
  template: `
     <h1>Comment form</h1>

     <form #heroForm="ngForm">
     <div class="form-group">
       <label for="name">Author</label>
       <input [(ngModel)]="model.author" name="author" type="text" class="form-control" id="name" required>

     <div class="form-group">
       <label for="alterEgo">Content</label>
       <textarea name="content" [(ngModel)]="model.content" class="form-control"></textarea>

     <button type="submit" class="btn btn-success">Submit</button>

     {{ model | json}}
  styles: ['']
export class CommentFormComponent {

  model = new GoodComment('Dima', 'Very nice!');

  submitted = false;

  onSubmit() { this.submitted = true; }


Angular did. Angular automatically creates and attaches an NgForm directive to the


The NgModel directive doesn’t just track state; it updates the control with special Angular CSS classes that reflect the state.

======= Шаблонные формы.


Other topics