angular / angular/angularfire

"AngularFireFunctions" documentation has two errors

Đang mở
#3,210 3 bình luận 1 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
TypeScript
Star
7.8k
Fork
2.2k
Merge trung bình
22 giờ 28 phút
Pull request đã merge (30 ngày)
6

Mô tả

The example code in the [AngularFireFunctions](https://github.com/angular/angularfire/blob/master/docs/functions/functions.md) documentation doesn't compile. Here's the provided code, with comments on the two lines that don't compile:

```ts
import { Component } from '@angular/core';
import { AngularFireFunctions } from '@angular/fire/compat/functions';

@Component({
selector: 'app-root',
template: `{ data$ | async }` // doesn't compile
})
export class AppComponent {
constructor(private fns: AngularFireFunctions) {
const callable = fns.httpsCallable('my-fn-name');
this.data$ = callable({ name: 'some-data' }); // doesn't compile
}
}
```

The `template` line needs double curly brackets:

```ts
template: `{{ data$ | async }}`
```

The next error is:

```bash
Property 'data$' does not exist on type 'AppComponent'.

6 template: `{{ data$ | async }}`,
```

I corrected this by making a variable `data$: any`.

This code now compiles:

```ts
import { Component } from '@angular/core';
import { AngularFireFunctions } from '@angular/fire/compat/functions';

@Component({
selector: 'app-component',
template: `{{ data$ | async }}`,
})
export class AppComponent {
data$: any;

constructor(private fns: AngularFireFunctions) {
const callable = fns.httpsCallable('my-fn-name');
this.data$ = callable({ name: 'some-data' });
}
}
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Mở docs/functions/functions.md và kiểm tra ví dụ AngularFireFunctions. Đối chiếu phép nội suy trong template và khai báo AppComponent với các lỗi TypeScript đã được báo cáo, sau đó xác minh rằng ví dụ đã sửa biên dịch được và khớp với cách sử dụng hàm callable được ghi trong tài liệu.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
angular, typescript
Lĩnh vực
documentation
Loại issue
Tài liệu
Độ khó
1/5
Thời gian dự kiến
Dưới một giờ
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
45/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.