why does this error/bug appears on angular
I am creating an angular project for front end with back and in python - flask, but, in the last time i tried to make a database appear the console shows a error... however the page updates correctly. Here are the code samples.
here is the place the error is shown but still shows the right data.
<div class=" w3-half" layout="column">
<div id="chartContainer2" style="margin-top:2%; height: 100%; width: 100%;">
<h3 class="titulo">YOUR TIME BANK: {{grafico.horas_aluno}}</h3>
<div style="display: block;">
<canvas baseChart
[data]="doughnutChartData2"
[labels]="doughnutChartLabels2"
[colors]="colors2"
[chartType]="doughnutChartType2"
[legend]="doughnutchartDisplay2"
(chartHover)="chartHovered2($event)"
(chartClick)="chartClicked2($event)"></canvas>
</div>
</div>
and here is the typescript that the call is refering to
import { Component, OnInit, NgModule } from '@angular/core';
import { GoogleChartsModule } from 'angular-google-charts';
import { HttpClient } from '@angular/common/http';
@Component({
selector: 'app-pagina',
templateUrl: './pagina.component.html',
styleUrls: ['./pagina.component.css']
})
@NgModule({
declarations: [PaginaComponent],
imports: [GoogleChartsModule.forRoot(),],
bootstrap: [PaginaComponent],
})
export class PaginaComponent implements OnInit {
serverData: JSON;
employeeData: JSON;
constructor(private http: HttpClient) { }
alunos:any;
grafico:JSON;
ngOnInit() {
this.http.get('http://127.0.0.1:5002/222222').subscribe(dados => {
console.log(dados)
this.alunos = [dados as JSON];
})
this.http.get('http://127.0.0.1:5002/chart/222222').subscribe(dados => {
console.log(dados)
this.grafico = dados as JSON;
})
}
public doughnutChartLabels2:string = ['Total time', 'Remaining time', 'Missing time'];
public colors2 = [{
backgroundColor: ['rgba(17, 168, 0, 1)','rgba(189, 0, 0, 1)', 'rgba(0, 72, 240, 1)'],
fillColor: 'rgba(47, 132, 71, 0.8)',
strokeColor: 'rgba(47, 132, 71, 0.8)',
highlightFill: 'rgba(47, 132, 71, 0.8)',
highlightStroke: 'rgba(47, 132, 71, 0.8)'
}];
public doughnutChartData2:number = [3,45,1];
public doughnutchartDisplay2 = false;
public titleChart2 = [{display:true}];
public doughnutChartType2:string = 'doughnut';
// events
public chartClicked2(e:any):void {
console.log(e);
}
public chartHovered2(e:any):void {
console.log(e);
}
}
and here is the error shown on console: ERROR TypeError: "_co.grafico is undefined"
javascript python angular typescript
add a comment |
I am creating an angular project for front end with back and in python - flask, but, in the last time i tried to make a database appear the console shows a error... however the page updates correctly. Here are the code samples.
here is the place the error is shown but still shows the right data.
<div class=" w3-half" layout="column">
<div id="chartContainer2" style="margin-top:2%; height: 100%; width: 100%;">
<h3 class="titulo">YOUR TIME BANK: {{grafico.horas_aluno}}</h3>
<div style="display: block;">
<canvas baseChart
[data]="doughnutChartData2"
[labels]="doughnutChartLabels2"
[colors]="colors2"
[chartType]="doughnutChartType2"
[legend]="doughnutchartDisplay2"
(chartHover)="chartHovered2($event)"
(chartClick)="chartClicked2($event)"></canvas>
</div>
</div>
and here is the typescript that the call is refering to
import { Component, OnInit, NgModule } from '@angular/core';
import { GoogleChartsModule } from 'angular-google-charts';
import { HttpClient } from '@angular/common/http';
@Component({
selector: 'app-pagina',
templateUrl: './pagina.component.html',
styleUrls: ['./pagina.component.css']
})
@NgModule({
declarations: [PaginaComponent],
imports: [GoogleChartsModule.forRoot(),],
bootstrap: [PaginaComponent],
})
export class PaginaComponent implements OnInit {
serverData: JSON;
employeeData: JSON;
constructor(private http: HttpClient) { }
alunos:any;
grafico:JSON;
ngOnInit() {
this.http.get('http://127.0.0.1:5002/222222').subscribe(dados => {
console.log(dados)
this.alunos = [dados as JSON];
})
this.http.get('http://127.0.0.1:5002/chart/222222').subscribe(dados => {
console.log(dados)
this.grafico = dados as JSON;
})
}
public doughnutChartLabels2:string = ['Total time', 'Remaining time', 'Missing time'];
public colors2 = [{
backgroundColor: ['rgba(17, 168, 0, 1)','rgba(189, 0, 0, 1)', 'rgba(0, 72, 240, 1)'],
fillColor: 'rgba(47, 132, 71, 0.8)',
strokeColor: 'rgba(47, 132, 71, 0.8)',
highlightFill: 'rgba(47, 132, 71, 0.8)',
highlightStroke: 'rgba(47, 132, 71, 0.8)'
}];
public doughnutChartData2:number = [3,45,1];
public doughnutchartDisplay2 = false;
public titleChart2 = [{display:true}];
public doughnutChartType2:string = 'doughnut';
// events
public chartClicked2(e:any):void {
console.log(e);
}
public chartHovered2(e:any):void {
console.log(e);
}
}
and here is the error shown on console: ERROR TypeError: "_co.grafico is undefined"
javascript python angular typescript
add a comment |
I am creating an angular project for front end with back and in python - flask, but, in the last time i tried to make a database appear the console shows a error... however the page updates correctly. Here are the code samples.
here is the place the error is shown but still shows the right data.
<div class=" w3-half" layout="column">
<div id="chartContainer2" style="margin-top:2%; height: 100%; width: 100%;">
<h3 class="titulo">YOUR TIME BANK: {{grafico.horas_aluno}}</h3>
<div style="display: block;">
<canvas baseChart
[data]="doughnutChartData2"
[labels]="doughnutChartLabels2"
[colors]="colors2"
[chartType]="doughnutChartType2"
[legend]="doughnutchartDisplay2"
(chartHover)="chartHovered2($event)"
(chartClick)="chartClicked2($event)"></canvas>
</div>
</div>
and here is the typescript that the call is refering to
import { Component, OnInit, NgModule } from '@angular/core';
import { GoogleChartsModule } from 'angular-google-charts';
import { HttpClient } from '@angular/common/http';
@Component({
selector: 'app-pagina',
templateUrl: './pagina.component.html',
styleUrls: ['./pagina.component.css']
})
@NgModule({
declarations: [PaginaComponent],
imports: [GoogleChartsModule.forRoot(),],
bootstrap: [PaginaComponent],
})
export class PaginaComponent implements OnInit {
serverData: JSON;
employeeData: JSON;
constructor(private http: HttpClient) { }
alunos:any;
grafico:JSON;
ngOnInit() {
this.http.get('http://127.0.0.1:5002/222222').subscribe(dados => {
console.log(dados)
this.alunos = [dados as JSON];
})
this.http.get('http://127.0.0.1:5002/chart/222222').subscribe(dados => {
console.log(dados)
this.grafico = dados as JSON;
})
}
public doughnutChartLabels2:string = ['Total time', 'Remaining time', 'Missing time'];
public colors2 = [{
backgroundColor: ['rgba(17, 168, 0, 1)','rgba(189, 0, 0, 1)', 'rgba(0, 72, 240, 1)'],
fillColor: 'rgba(47, 132, 71, 0.8)',
strokeColor: 'rgba(47, 132, 71, 0.8)',
highlightFill: 'rgba(47, 132, 71, 0.8)',
highlightStroke: 'rgba(47, 132, 71, 0.8)'
}];
public doughnutChartData2:number = [3,45,1];
public doughnutchartDisplay2 = false;
public titleChart2 = [{display:true}];
public doughnutChartType2:string = 'doughnut';
// events
public chartClicked2(e:any):void {
console.log(e);
}
public chartHovered2(e:any):void {
console.log(e);
}
}
and here is the error shown on console: ERROR TypeError: "_co.grafico is undefined"
javascript python angular typescript
I am creating an angular project for front end with back and in python - flask, but, in the last time i tried to make a database appear the console shows a error... however the page updates correctly. Here are the code samples.
here is the place the error is shown but still shows the right data.
<div class=" w3-half" layout="column">
<div id="chartContainer2" style="margin-top:2%; height: 100%; width: 100%;">
<h3 class="titulo">YOUR TIME BANK: {{grafico.horas_aluno}}</h3>
<div style="display: block;">
<canvas baseChart
[data]="doughnutChartData2"
[labels]="doughnutChartLabels2"
[colors]="colors2"
[chartType]="doughnutChartType2"
[legend]="doughnutchartDisplay2"
(chartHover)="chartHovered2($event)"
(chartClick)="chartClicked2($event)"></canvas>
</div>
</div>
and here is the typescript that the call is refering to
import { Component, OnInit, NgModule } from '@angular/core';
import { GoogleChartsModule } from 'angular-google-charts';
import { HttpClient } from '@angular/common/http';
@Component({
selector: 'app-pagina',
templateUrl: './pagina.component.html',
styleUrls: ['./pagina.component.css']
})
@NgModule({
declarations: [PaginaComponent],
imports: [GoogleChartsModule.forRoot(),],
bootstrap: [PaginaComponent],
})
export class PaginaComponent implements OnInit {
serverData: JSON;
employeeData: JSON;
constructor(private http: HttpClient) { }
alunos:any;
grafico:JSON;
ngOnInit() {
this.http.get('http://127.0.0.1:5002/222222').subscribe(dados => {
console.log(dados)
this.alunos = [dados as JSON];
})
this.http.get('http://127.0.0.1:5002/chart/222222').subscribe(dados => {
console.log(dados)
this.grafico = dados as JSON;
})
}
public doughnutChartLabels2:string = ['Total time', 'Remaining time', 'Missing time'];
public colors2 = [{
backgroundColor: ['rgba(17, 168, 0, 1)','rgba(189, 0, 0, 1)', 'rgba(0, 72, 240, 1)'],
fillColor: 'rgba(47, 132, 71, 0.8)',
strokeColor: 'rgba(47, 132, 71, 0.8)',
highlightFill: 'rgba(47, 132, 71, 0.8)',
highlightStroke: 'rgba(47, 132, 71, 0.8)'
}];
public doughnutChartData2:number = [3,45,1];
public doughnutchartDisplay2 = false;
public titleChart2 = [{display:true}];
public doughnutChartType2:string = 'doughnut';
// events
public chartClicked2(e:any):void {
console.log(e);
}
public chartHovered2(e:any):void {
console.log(e);
}
}
and here is the error shown on console: ERROR TypeError: "_co.grafico is undefined"
javascript python angular typescript
javascript python angular typescript
asked Nov 20 '18 at 3:07


Astral ThinkerAstral Thinker
3010
3010
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Try using safe navigation operator as the data loads asynchronously from the api call
<h3 class="titulo">YOUR TIME BANK: {{grafico?.horas_aluno}}</h3>
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53385637%2fwhy-does-this-error-bug-appears-on-angular%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Try using safe navigation operator as the data loads asynchronously from the api call
<h3 class="titulo">YOUR TIME BANK: {{grafico?.horas_aluno}}</h3>
add a comment |
Try using safe navigation operator as the data loads asynchronously from the api call
<h3 class="titulo">YOUR TIME BANK: {{grafico?.horas_aluno}}</h3>
add a comment |
Try using safe navigation operator as the data loads asynchronously from the api call
<h3 class="titulo">YOUR TIME BANK: {{grafico?.horas_aluno}}</h3>
Try using safe navigation operator as the data loads asynchronously from the api call
<h3 class="titulo">YOUR TIME BANK: {{grafico?.horas_aluno}}</h3>
answered Nov 20 '18 at 3:10


SajeetharanSajeetharan
118k29166227
118k29166227
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53385637%2fwhy-does-this-error-bug-appears-on-angular%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown