誰もがこれで私を助けることができたら、それは非常に感謝します。私はルータfirebase
の機能を使用することができません。ファイアベース機能内でルータオブジェクトを使用するにはどうすればいいですか?
import { Component, OnInit } from '@angular/core';
import { FirebaseService } from '../../services/firebase.service';
import * as firebase from 'firebase';
import { Router } from '@angular/router';
@Component({
selector: 'app-listings',
templateUrl: './listings.component.html',
styleUrls: ['./listings.component.css']
})
export class ListingsComponent implements OnInit {
listings: any;
constructor(
private firebaseService: FirebaseService,
public router: Router
) {
これは私がルータを使用することができないfirebase
の機能です。
firebase.auth().onAuthStateChanged(function(user) {
if (user) {
// User is signed in.
console.log('loggedIn');
} else {
// No user is signed in.
console.log('not loggedIn');
コンソールも正常に動作しているようです。
this.router.navigate(['/']);
}
});
}
ngOnInit() {
this.firebaseService.getListings().subscribe(listings => {
this.listings = listings;
console.log(listings);
});
}
}
あなたがFirebase SDKを使用して代わりのAngularFireの[認証](https://github.com/angular/angularfire2/blobている理由の任意の特定の理由/master/docs/5-user-authentication.md)? –