FGF-College-Work / Forum

:beer: Espaço dedicado a discussões e tira dúvida sobre disciplinas e conteúdo tecnológico.
MIT License
13 stars 4 forks source link

Type 'Observable<any>' is not assignable to type '[]' #62

Open marcialwushu opened 6 years ago

marcialwushu commented 6 years ago

Typescript Error

Type 'Observable<any[]>' is not assignable to type 'Observable'. Types of property 'subscribe' are incompatible. Type '{ (observer?: PartialObserver<any[]>): Subscription; (next?: (value: any[]) => void, error?: (err...' is not assignable to type 'Subscribe'. Types of parameters 'observer' and 'next' are incompatible. Type 'NextFn' is not assignable to type 'PartialObserver<any[]>'. Type 'NextFn' is not assignable to type 'CompletionObserver<any[]>'. Property 'complete' is missing in type 'NextFn'.

marcialwushu commented 6 years ago

 constructor(public navCtrl: NavController, private contact: ContactListService) {

  this.contactList$ = this.contact   .getContactList()

marcialwushu commented 6 years ago

productList should be Product[] not Observable. So assign productList value from getProducts subscribe method, where you will retrieve array of Product

onSelect(typeid) {
  this.productService.getProducts()
    .filter((item)=>item.ptypeid == typeid)
    .subscribe((products) => {
       this.productList = products;
    });
}