Here's a snippet of code for a component in Angular:
import { Component, OnInit } from '@angular/core';
import { FormArray, FormControl, FormGroup, NgForm } from '@angular/forms';
import { ActivatedRoute } from '@angular/router';
import { CisvcService } from 'src/app/services/cisvc.service';
@Component({
selector: 'app-cambio',
templateUrl: './cambio.component.html',
styleUrls: ['./cambio.component.css']
})
export class CambioComponent implements OnInit {
idproyecto: any;
tipos: any[] = [];
areas: any[] = [];
cbAreas: boolean[] = [];
constructor(private activatedRoute: ActivatedRoute, private svc: CisvcService ) {}
ngOnInit(): void {
this.activatedRoute.params.subscribe( params => {
this.idproyecto = params['id'];
});
this.svc.getTipos().subscribe( (data: any[]) => {
console.log(data);
this.tipos = data;
});
this.svc.getAreas().subscribe( (data: any[]) => {
this.areas = data;
});
console.log(this.areas);
console.log(this.tipos);
}
formSubmit( forma: NgForm ){
if (forma.invalid){
console.log('invalid data');
return;
}
}
}
I am encountering an issue where data is being received from the service but is not populating the arrays `typos` and `areas`. Any insight on what might be causing this would be greatly appreciated.