简体   繁体   English

“void”类型上不存在属性“管道”Angular 6

[英]Property 'pipe' does not exist on type 'void' Angular 6

I don't understand the cause of the problem.我不明白问题的原因。 my code from Service File and i get Error我的Service文件中的代码,我得到错误

  1. Property 'pipe' does not exist on type 'void'.类型“void”上不存在属性“管道”。
  2. Property '$key' does not exist on type '{}'.类型“{}”上不存在属性“$key”。

在此处输入图像描述

import { Injectable } from '@angular/core';
import { AngularFireDatabase, AngularFireList } from '@angular/fire/database';
import { switchMap } from 'rxjs/operators';
import { Observable } from 'rxjs';
@Injectable({
  providedIn: 'root'
})
export class CoursesService {

  constructor(private af: AngularFireDatabase) { }

  findAllCourses(): AngularFireList<any> {
    return this.af.list('courses');
  }

  findCourseDtl(coursUrl:string){
   this.af.list('courses', ref => ref.orderByChild('url').equalTo(coursUrl)).valueChanges()
  }

  findLessonsForCours(coursUrl:string): Observable<any>{
    return this.findCourseDtl(coursUrl)
   .pipe(switchMap(course => this.af.list('lessonsPerCourse/'+ course.$key ).valueChanges()));


}

}

You didn't return any value in the findCourseDtl function.您没有在findCourseDtl function 中返回任何值。

This may be what you intended:这可能是您的意图:

findCourseDtl(coursUrl:string){
  return this.af.list('courses', ref => ref.orderByChild('url').equalTo(coursUrl)).valueChanges()
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM