angular / angular/angularfire

"AngularFireFunctions" documentation has two errors

未关闭
#3,210 3 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
TypeScript
星标
7.8k
派生
2.2k
平均合并
22 小时 28 分钟
30 天内合并 PR
6

描述

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' });
}
}
```

贡献指南

打开贡献指南

调研方向

打开 docs/functions/functions.md 并检查 AngularFireFunctions 示例。根据报告的 TypeScript 错误检查模板插值和 AppComponent 声明,然后验证修正后的示例能够编译,并符合文档中所述的可调用函数用法。

由索引模型根据 Issue 内容生成。

评估

技术栈
angular, typescript
领域
documentation
Issue 类型
文档
难度
1/5
预计耗时
1 小时以内
活跃度
停滞
描述清晰度
描述清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。