Currently, I am utilizing Angular 4 to develop my website. However, I am encountering issues while attempting to create an Object with a vector of objects inside it. This approach is not yielding the desired results for me. Here's a snippet of my code:
Object 1 (disciplinaStatus.module.ts)
export class DisciplinaStatus{
constructor(public codigo: string,
public nome: string,
public status: string,
public professor:string,
public cargaHoraria:string,
public nota: number) {}
}
Object 2 (historicoData.module.ts)
import { DisciplinaStatus } from './disciplinaStatus.model';
export class HistoricoData {
constructor(public periodo: string,
public historico: DisciplinaStatus[]) {} //Encountering an issue here!!!
}
Snippet from my component TypeScript code:
import { Component, OnInit } from '@angular/core';
import { DisciplinaStatus } from './models/disciplinaStatus.model';
import { HistoricoData } from './models/historicoData.model';
@Component({
selector: 'historico-a-component',
templateUrl: './historico-a.component.html',
styleUrls: ['./historico-a.component.css']
})
export class HistoricoAComponent implements OnInit {
constructor(historico: HistoricoData[]) {
historico = [
new HistoricoData('2016/1', [
new DisciplinaStatus('001','Redes 1','Completo','Everthon Valadão','60',71.5),
new DisciplinaStatus('002','Compiladores','Completo','Walace','60',45.5)
]),
new HistoricoData('2016/2', [
new DisciplinaStatus('001','AED','Completo','Diego Melo','60',22.5),
new DisciplinaStatus('002','Teoria','Completo','Diego Melo','60',89.5)
])
];
}
The ERROR Message:
ng:///AppModule/AppComponent.ngfactory.js:7 ERROR Error: StaticInjectorError(AppModule)[HistoricoAComponent -> Array]:
StaticInjectorError(Platform: core)[HistoricoAComponent -> Array]: NullInjectorError: No provider for Array! at NullInjector.get (webpack-internal:///../../../core/esm5/core.js:1209) at resolveToken (webpack-internal:///../../../core/esm5/core.js:1507) at tryResolveToken (webpack-internal:///../../../core/esm5/core.js:1449) at StaticInjector.get (webpack-internal:///../../../core/esm5/core.js:1317) at resolveToken (webpack-internal:///../../../core/esm5/core.js:1507) at tryResolveToken (webpack-internal:///../../../core/esm5/core.js:1449) at StaticInjector.get (webpack-internal:///../../../core/esm5/core.js:1317) at resolveNgModuleDep (webpack-internal:///../../../core/esm5/core.js:11051) at NgModuleRef.get (webpack-internal:///../../../core/esm5/core.js:12284) at resolveDep (webpack-internal:///../../../core/esm5/core.js:12774)