TypeError: Cannot read property 'hasData' of undefined


#1

TypeError: Cannot read property ‘hasData’ of undefined

My code is :

if(this.cartService.hasData()){ ---- }

and the cartService code is :

hasData(){
return this.data.items.length>0;
}

Getting this error on console :

ERROR TypeError: Cannot read property ‘hasData’ of undefined
at RestaurantListPage.webpackJsonp.305.RestaurantListPage.selectRestaurant (restaurant-list.ts:102).

Please help me, Thanks


#2

I resolved this issue by creating new service provider for cartservice