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 摘要。