- Home
- Forum
- JavaScript - EJ 2
- Error: Cannot read property 'count' of undefined. Databinding Web API Angular 2
Error: Cannot read property 'count' of undefined. Databinding Web API Angular 2
Hi.
I get this error when I try to get data from Web API using Angular 2
This is the full error message:
ERROR TypeError: Cannot read property 'count' of undefined
at Ajax.fnSuccess [as onSuccess] (manager.js:240)
at Ajax.webpackJsonp.../../../../@syncfusion/ej2-base/dist/es6/ajax.js.Ajax.successHandler (ajax.js:68)
at Ajax.webpackJsonp.../../../../@syncfusion/ej2-base/dist/es6/ajax.js.Ajax.stateChange (ajax.js:95)
at XMLHttpRequest._this.httpRequest.onreadystatechange [as __zone_symbol__ON_PROPERTYreadystatechange] (ajax.js:53)
at XMLHttpRequest.wrapFn (zone.js:1166)
at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:425)
at Object.onInvokeTask (core.es5.js:3881)
at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:424)
at Zone.webpackJsonp.../../../../zone.js/dist/zone.js.Zone.runTask (zone.js:192)
at ZoneTask.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneTask.invokeTask [as invoke] (zone.js:499)
This is my .html component code
This is my .ts component code
[...]
And this is the API's response
Thank you.
I get this error when I try to get data from Web API using Angular 2
This is the full error message:
ERROR TypeError: Cannot read property 'count' of undefined
at Ajax.fnSuccess [as onSuccess] (manager.js:240)
at Ajax.webpackJsonp.../../../../@syncfusion/ej2-base/dist/es6/ajax.js.Ajax.successHandler (ajax.js:68)
at Ajax.webpackJsonp.../../../../@syncfusion/ej2-base/dist/es6/ajax.js.Ajax.stateChange (ajax.js:95)
at XMLHttpRequest._this.httpRequest.onreadystatechange [as __zone_symbol__ON_PROPERTYreadystatechange] (ajax.js:53)
at XMLHttpRequest.wrapFn (zone.js:1166)
at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:425)
at Object.onInvokeTask (core.es5.js:3881)
at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:424)
at Zone.webpackJsonp.../../../../zone.js/dist/zone.js.Zone.runTask (zone.js:192)
at ZoneTask.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneTask.invokeTask [as invoke] (zone.js:499)
This is my .html component code
<ej-grid #gridVacunas [dataSource]='data' [enableHover]="false" [allowSelection]="true" [selectionSettings]="selectOptions">
<e-columns>
<e-column type='checkbox' width='50'>e-column>
<e-column field='codigo' headerText='Código' width='120'>e-column>
<e-column field='nombre' headerText='Nombre' width='250'>e-column>
e-columns>
ej-grid>
This is my .ts component code
import { DataManager, WebApiAdaptor } from '@syncfusion/ej2-data';
[...]
export class FormComponent implements OnInit {
public data: DataManager;
ngOnInit() {
this.selectOptions = { persistSelection: true };
this.data = new DataManager({
url: '/api/vacunas',
adaptor: new WebApiAdaptor
});
}
And this is the API's response
- {items: [,…], count: 18}
- count:18
- items:[,…]
- 0:{id: 1, codigo: "bf", nombre: "Vacuna leishmania", cadencia: 345, cadenciaReal: 365, edadMinima: 6,…}
- 1:{id: 2, codigo: "COR", nombre: "Vacuna coronavirus", cadencia: 345, cadenciaReal: 345, edadMinima: 2,…}
- 2:{id: 3, codigo: "duramu", nombre: "vacuna duramune 8", cadencia: 0, cadenciaReal: 0, edadMinima: 0,…}
- [...]
Thank you.
SIGN IN To post a reply.
3 Replies
PS
Pavithra Subramaniyam
Syncfusion Team
December 8, 2017 05:12 PM UTC
Hi Luis,
We have validated your query and we are not able to reproduce the reported issue. We have prepared a simple sample based on your code example. Please refer the following sample link.
Could you please replicate your issue in the above sample and get back to us with more information regarding the issue so that we can analyse based on that and provide you better solution? The information provided would be a great help for us to resolve this issue.
Regards,
Pavithra S.
LL
Luis Lora
December 11, 2017 01:47 PM UTC
OK, I'll try to replicate and send you.
Thank you!
Thank you!
PS
Pavithra Subramaniyam
Syncfusion Team
December 12, 2017 02:50 PM UTC
Hi Luis,
Thanks for the update.
Please let me know if you have any queries.
Regards,
Pavithra S.
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
LL Luis Lora
- Dec 7, 2017 08:42 AM UTC
- Dec 12, 2017 02:50 PM UTC