A more Angular 2 specific solution
For the Angular 2 Firebase course we are just going to only create angular-cli apps. At present the only way I know to use Rosefire is via vanilla js. That actually works fine, but it seems like there should be a more elegant angular way to do it. Ideally utilizing AngularFire. So you can assume students have made the app with angular-cli and they are setup to use AngularFire.
To do it today we use vanilla js, and declare a var that exist in the javascript and it works fine, but it seems like there should be a .ts way to do it. Even an
npm install rosefire --save
way to do it instead of the code in our current approach...
import { Injectable, EventEmitter } from '@angular/core';
declare var firebase: any; declare var Rosefire: any;
@Component blah blah blah... export class Name { login() { Rosefire.signIn(this.registryToken, (err, token) => { firebase.auth().signInWithCustomToken(token).catch(this.errorCallback); }); };
logout() { firebase.auth().signOut().catch(this.errorCallback); }; }