Answer the question
In order to leave comments, you need to log in
How to properly handle a form with toggled components?
Good day,
today I stumbled upon a problem related to forms, or rather, to rummaged components:
<form #testForm="ngForm">
<input type="text" name="test1" ngModel>
<test-input></test-input>
<test-select></test-select>
<button (click)=test(testForm.value)>Test</button>
</form>
Answer the question
In order to leave comments, you need to log in
What does shared components mean?
<test-input></test-input>
<test-select></test-select>
import { Component, Input } from '@angular/core';
@Component({
selector: 'test-input'
})
export class TestInputComponent {
// Тут значение принимается!
// Тип значения должен стоять тот, который ожидается
// @Input() - это то что называется декоратором, он служит для передачи значений между директивами
@Input()
value: any;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question