import { FormGroup, FormBuilder } from '@angular/forms';
@Component({
...
})
export class ComponentName {
form: FormGroup;
constructor(
private fb: FormBuilder
){
this.form = this.fb.group({
test3: [...]
});
}
}
setSelect(event) {
this.form.controls['test3'].setValue(event);
}
@Component({
selector: 'parent',
template: `<section>
<my-cool-child-component [state]="someData"></my-cool-child-component>
<button (click)="clickMe()"></button>
</section>`,
styles: ``,
})
export class ParentComponent {
someData;
clickMe() {
this.someData = ...;
}
}
import { Input } from '@angular/core';
@Component({
selector: 'my-cool-child-component',
template: `<div><h1>{{state}}</h1></div>`,
styles: ``,
})
export class MyCoolChildComponent {
@Input() state;
}