M
M
Maxim Ivanov2017-01-08 00:07:02
Angular
Maxim Ivanov, 2017-01-08 00:07:02

Why does Angular 2 strip its own attributes?

<div class="row-vertical-center">

  <div class="row row-vertical-center">
      <div class="fieldset">
      	<form class="form" [formGroup]="complexForm" (ngSubmit)="submitForm(complexForm.value)">
      
            <div class="input-field col s12">
              <input placeholder="Введите логин" id="login" type="text" class="validate" [formControl]="complexForm.controls['login']" autofocus>
              <i class="form-icon material-icons">perm_identity</i>
            </div>

            <div class="input-field col s12">
              <input placeholder="Введите пароль" id="password" type="password" class="validate" [formControl]="complexForm.controls['password']">
              <i class="form-icon material-icons">vpn_key</i>
            </div>

            <div class="input-field col s12">
              <a class="form-send waves-effect waves-light btn" (click)="test()">Авторизоваться</a>
            </div>
         

      	</form>
      </div>
    </div>

</div>

I sketched a form according to the example:
https://scotch.io/tutorials/angular-2-form-validation
import { Component, ViewEncapsulation } from '@angular/core';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
/* declare var $:any; */

@Component({
  selector: 'my-app', // <my-app></my-app>
  templateUrl: './app.component.html',
  styleUrls: [ './app.component.scss' ],
  encapsulation: ViewEncapsulation.None
})
export class AppComponent {

  complexForm : FormGroup;

  constructor(fb: FormBuilder){
    this.complexForm = fb.group({
      'login' : [null, Validators.required],
      'password': [null, Validators.required],
    });

    console.log(this.complexForm)
  }

  submitForm(value: any){
    console.log(value);
  }

  test() {
    console.log(1)
  }

}

As a result, when everything is assembled, there is nothing at all in the html tree (neither click, nor ngSubmit, ng-attributes), and nothing works, how is this possible?
69cac959333c48c9ab6076270d8536ef.jpg

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question