Аргумент типа '{query: {orderByChild: string; equalTo: строка; }; } 'нельзя назначить параметру типа' QueryFn '.
и
InvalidPipeArgument: '[объект объекта]' для канала 'AsyncPipe'
//'order.service file'
import { ShoppingCartService } from './shopping-cart.service';
import { AngularFireDatabase } from 'angularfire2/database';
import { Injectable } from '@angular/core';
@Injectable()
export class OrderService {
constructor(private db: AngularFireDatabase, private
shoppingCartService: ShoppingCartService) { }
async placeOrder(order) {
let result = await this.db.list('/orders').push(order);
this.shoppingCartService.clearCart();
return result;
}
getOrders() {
return this.db.list('/orders');
}
getOrdersByUser(userId: string) {
return this.db.list('/orders', {
query: { \\This is where the error is
orderByChild: 'userId',
equalTo: userId
}
});
}
}
**********************************************
//admin-order file
//this file has no error
import { Order } from './../../models/order';
import { OrderService } from './../../order.service';
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-admin-orders',
templateUrl: './admin-orders.component.html',
styleUrls: ['./admin-orders.component.css']
})
export class AdminOrdersComponent {
orders$;
constructor(private orderService: OrderService) {
this.orders$ = orderService.getOrders();
}
}
*******************************************
//myorders file. This file also has no errors
import { AuthService } from './../auth.service';
import { OrderService } from './../order.service';
import { Component, OnInit } from '@angular/core';
import 'rxjs/add/operator/switchMap';
@Component({
selector: 'app-my-orders',
templateUrl: './my-orders.component.html',
styleUrls: ['./my-orders.component.css']
})
export class MyOrdersComponent {
orders$;
constructor(
private authService: AuthService,
private orderService: OrderService) {
this.orders$ = authService.user$.switchMap(u =>
orderService.getOrdersByUser(u.uid));
}
}
********************************
//html file for myorders as well as admin orders but getting an error at
//asyncpipe
<h1>Orders</h1>
<table class="table">
<thead>
<tr>
<th>Customer</th>
<th>Date</th>
<th></th>
</tr>
</thead>
<tbody>
<tr *ngFor="let order of orders$ | async">
<td>{{ order.shipping.name }}</td>
<td>{{ order.datePlaced | date}}</td>
<td>
<a href="#">View</a>
</td>
</tr>
</tbody>
</table>
// Ошибка для моего htmlfile
InvalidPipeArgument: '[объект объекта]' для канала 'AsyncPipe'
// Ошибка для моего файла службы заказа
Аргумент типа '{query: {orderByChild: string; equalTo: строка; }; } 'нельзя назначить параметру типа' QueryFn '.