0
Good night, you guys.
In Angular 6, I have the following code:
import { Component, OnInit } from '@angular/core'
import { FormGroup, FormBuilder } from '@angular/forms';
@Component({
selector: 'app-form',
templateUrl: './form.component.html',
styleUrls: ['./form.component.scss'],
})
export class FormComponent implements OnInit {
formulario: FormGroup
constructor(private formBuilder: FormBuilder) {}
ngOnInit() {
this.formulario = this.formBuilder.group({
pesquisa: [null],
})
}
teste() {
console.log(this.formulario.value.pesquisa)
}
}
How can I export "this.formulario" so I can use it in a service?
I am capturing the data typed in an input via ngSubmit and want to pass it to the url of an API (which is defined in a service).
I am beginner and did not find solutions clear enough for my understanding.
Thank you.