angularfire icon indicating copy to clipboard operation
angularfire copied to clipboard

"AngularFireFunctions" documentation has two errors

Open tdkehoe opened this issue 2 years ago • 3 comments

The example code in the AngularFireFunctions documentation doesn't compile. Here's the provided code, with comments on the two lines that don't compile:

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:

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

The next error is:

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:

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

tdkehoe avatar Apr 17 '22 18:04 tdkehoe

This issue does not seem to follow the issue template. Make sure you provide all the required information.

google-oss-bot avatar Apr 17 '22 18:04 google-oss-bot

Also, a sentence doesn't seem grammatical:

Notice that calling httpsCallable() does not initiate the request. It creates a function, which when called creates an Observable, subscribe or convert it to a Promise to initiate the request.

Maybe that should be:

Notice that calling httpsCallable() does not initiate the request. It creates a function, which when called creates an Observable. Subscribe to the Observable or convert it to a Promise to initiate the request.

tdkehoe avatar Apr 17 '22 18:04 tdkehoe

Where is the latest documentation about AngularFire with Cloud Functions?
In Node.js functions.https.onCall and Angular httpsCallable

sorcamarian avatar Dec 31 '23 14:12 sorcamarian