angular / angular/angularfire

"AngularFireFunctions" documentation has two errors

Offen
#3,210 3 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
TypeScript
Sterne
7.8k
Forks
2.2k
Ø Merge
22 Std. 28 Min.
Gemergte PRs (30 T.)
6

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Öffne docs/functions/functions.md und prüfe das AngularFireFunctions-Beispiel. Vergleiche die Template-Interpolation und die Deklaration von AppComponent mit den gemeldeten TypeScript-Fehlern und verifiziere anschließend, dass das korrigierte Beispiel kompiliert und der dokumentierten Verwendung von Callable Functions entspricht.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
angular, typescript
Bereich
documentation
Issue-Typ
Dokumentation
Schwierigkeit
1/5
Geschätzter Aufwand
Unter einer Stunde
Aktivitätsstatus
Veraltet
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.