Empty page with *ngFor when i try to retrive data from firebase
up vote
1
down vote
favorite
I'm practicing some Angular/Ionic and am having a bit of a hard time figuring out why my *ngFor does not display my data from firebase.
I have an offre.model.ts that looks like this:
offre.model.ts
export interface Offre
key? : string ;
titre : string ;
secteur : string ;
ville : string ;
an offreList.service that looks like this :
import Injectable from "@angular/core";
import Offre from "../../models/offre/offre.model";
import AngularFireDatabase from "angularfire2/database";
@Injectable()
export class OffreListeService
private offreListeRef = this.db.list<Offre>('offre_List') ;
constructor(private db : AngularFireDatabase)
getOffreList()
return this.offreListeRef;
addOffre(offre : Offre)
return this.offreListeRef.push(offre) ;
Patron.ts
import Component from '@angular/core';
import IonicPage, NavController, NavParams from 'ionic-angular';
import OffreListeService from
'../../services/offreListe/offreListe.service';
import Observable from 'rxjs';
import Offre from '../../models/offre/offre.model';
import 'rxjs/Rx';
@IonicPage()
@Component(
selector: 'page-patron',
templateUrl: 'patron.html',
)
export class PatronPage
offreList$ : Observable<Offre> ;
constructor(public navCtrl: NavController, public navParams: NavParams,
private offrep : OffreListeService)
this.offreList$ = this.offrep.getOffreList()
.snapshotChanges()
.map(
changes =>
return changes.map(c => (
key : c.payload.key,
...c.payload.val(),
));
);
console.log(this.offreList$);
ionViewDidLoad()
console.log('ionViewDidLoad PatronPage');
patron.html
<ion-item-sliding *ngFor = "let offre of offresList$ | async">
<ion-item >
titre : offre.titre
secteur : offre.secteur
ville : offre.key
</ion-item>
</ion-item-sliding>
So when I do that ngFor in my home.html, it simply prints nothing
Could you anyone help me with this, please?
I spent 3 days trying to resolve this problem
Cheers guys!
enter image description here
angular
add a comment |
up vote
1
down vote
favorite
I'm practicing some Angular/Ionic and am having a bit of a hard time figuring out why my *ngFor does not display my data from firebase.
I have an offre.model.ts that looks like this:
offre.model.ts
export interface Offre
key? : string ;
titre : string ;
secteur : string ;
ville : string ;
an offreList.service that looks like this :
import Injectable from "@angular/core";
import Offre from "../../models/offre/offre.model";
import AngularFireDatabase from "angularfire2/database";
@Injectable()
export class OffreListeService
private offreListeRef = this.db.list<Offre>('offre_List') ;
constructor(private db : AngularFireDatabase)
getOffreList()
return this.offreListeRef;
addOffre(offre : Offre)
return this.offreListeRef.push(offre) ;
Patron.ts
import Component from '@angular/core';
import IonicPage, NavController, NavParams from 'ionic-angular';
import OffreListeService from
'../../services/offreListe/offreListe.service';
import Observable from 'rxjs';
import Offre from '../../models/offre/offre.model';
import 'rxjs/Rx';
@IonicPage()
@Component(
selector: 'page-patron',
templateUrl: 'patron.html',
)
export class PatronPage
offreList$ : Observable<Offre> ;
constructor(public navCtrl: NavController, public navParams: NavParams,
private offrep : OffreListeService)
this.offreList$ = this.offrep.getOffreList()
.snapshotChanges()
.map(
changes =>
return changes.map(c => (
key : c.payload.key,
...c.payload.val(),
));
);
console.log(this.offreList$);
ionViewDidLoad()
console.log('ionViewDidLoad PatronPage');
patron.html
<ion-item-sliding *ngFor = "let offre of offresList$ | async">
<ion-item >
titre : offre.titre
secteur : offre.secteur
ville : offre.key
</ion-item>
</ion-item-sliding>
So when I do that ngFor in my home.html, it simply prints nothing
Could you anyone help me with this, please?
I spent 3 days trying to resolve this problem
Cheers guys!
enter image description here
angular
does the console log of the data show something? If yes then you know your request to firebase is working OK. Is the image of your console output?
– Steve
Nov 9 at 22:05
thanks for your reply, No the console log show me : Observable _isScalar: false, source: Observable, operator: MapOperator operator: MapOperator project: ƒ (changes) thisArg: undefined proto: Object source: Observable _isScalar: false, _subscribe: ƒ _isScalar: false proto: Object
– mostafa zouhair
Nov 9 at 22:33
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I'm practicing some Angular/Ionic and am having a bit of a hard time figuring out why my *ngFor does not display my data from firebase.
I have an offre.model.ts that looks like this:
offre.model.ts
export interface Offre
key? : string ;
titre : string ;
secteur : string ;
ville : string ;
an offreList.service that looks like this :
import Injectable from "@angular/core";
import Offre from "../../models/offre/offre.model";
import AngularFireDatabase from "angularfire2/database";
@Injectable()
export class OffreListeService
private offreListeRef = this.db.list<Offre>('offre_List') ;
constructor(private db : AngularFireDatabase)
getOffreList()
return this.offreListeRef;
addOffre(offre : Offre)
return this.offreListeRef.push(offre) ;
Patron.ts
import Component from '@angular/core';
import IonicPage, NavController, NavParams from 'ionic-angular';
import OffreListeService from
'../../services/offreListe/offreListe.service';
import Observable from 'rxjs';
import Offre from '../../models/offre/offre.model';
import 'rxjs/Rx';
@IonicPage()
@Component(
selector: 'page-patron',
templateUrl: 'patron.html',
)
export class PatronPage
offreList$ : Observable<Offre> ;
constructor(public navCtrl: NavController, public navParams: NavParams,
private offrep : OffreListeService)
this.offreList$ = this.offrep.getOffreList()
.snapshotChanges()
.map(
changes =>
return changes.map(c => (
key : c.payload.key,
...c.payload.val(),
));
);
console.log(this.offreList$);
ionViewDidLoad()
console.log('ionViewDidLoad PatronPage');
patron.html
<ion-item-sliding *ngFor = "let offre of offresList$ | async">
<ion-item >
titre : offre.titre
secteur : offre.secteur
ville : offre.key
</ion-item>
</ion-item-sliding>
So when I do that ngFor in my home.html, it simply prints nothing
Could you anyone help me with this, please?
I spent 3 days trying to resolve this problem
Cheers guys!
enter image description here
angular
I'm practicing some Angular/Ionic and am having a bit of a hard time figuring out why my *ngFor does not display my data from firebase.
I have an offre.model.ts that looks like this:
offre.model.ts
export interface Offre
key? : string ;
titre : string ;
secteur : string ;
ville : string ;
an offreList.service that looks like this :
import Injectable from "@angular/core";
import Offre from "../../models/offre/offre.model";
import AngularFireDatabase from "angularfire2/database";
@Injectable()
export class OffreListeService
private offreListeRef = this.db.list<Offre>('offre_List') ;
constructor(private db : AngularFireDatabase)
getOffreList()
return this.offreListeRef;
addOffre(offre : Offre)
return this.offreListeRef.push(offre) ;
Patron.ts
import Component from '@angular/core';
import IonicPage, NavController, NavParams from 'ionic-angular';
import OffreListeService from
'../../services/offreListe/offreListe.service';
import Observable from 'rxjs';
import Offre from '../../models/offre/offre.model';
import 'rxjs/Rx';
@IonicPage()
@Component(
selector: 'page-patron',
templateUrl: 'patron.html',
)
export class PatronPage
offreList$ : Observable<Offre> ;
constructor(public navCtrl: NavController, public navParams: NavParams,
private offrep : OffreListeService)
this.offreList$ = this.offrep.getOffreList()
.snapshotChanges()
.map(
changes =>
return changes.map(c => (
key : c.payload.key,
...c.payload.val(),
));
);
console.log(this.offreList$);
ionViewDidLoad()
console.log('ionViewDidLoad PatronPage');
patron.html
<ion-item-sliding *ngFor = "let offre of offresList$ | async">
<ion-item >
titre : offre.titre
secteur : offre.secteur
ville : offre.key
</ion-item>
</ion-item-sliding>
So when I do that ngFor in my home.html, it simply prints nothing
Could you anyone help me with this, please?
I spent 3 days trying to resolve this problem
Cheers guys!
enter image description here
angular
angular
edited Nov 9 at 21:48
Frank van Puffelen
220k25361387
220k25361387
asked Nov 9 at 21:30
mostafa zouhair
133
133
does the console log of the data show something? If yes then you know your request to firebase is working OK. Is the image of your console output?
– Steve
Nov 9 at 22:05
thanks for your reply, No the console log show me : Observable _isScalar: false, source: Observable, operator: MapOperator operator: MapOperator project: ƒ (changes) thisArg: undefined proto: Object source: Observable _isScalar: false, _subscribe: ƒ _isScalar: false proto: Object
– mostafa zouhair
Nov 9 at 22:33
add a comment |
does the console log of the data show something? If yes then you know your request to firebase is working OK. Is the image of your console output?
– Steve
Nov 9 at 22:05
thanks for your reply, No the console log show me : Observable _isScalar: false, source: Observable, operator: MapOperator operator: MapOperator project: ƒ (changes) thisArg: undefined proto: Object source: Observable _isScalar: false, _subscribe: ƒ _isScalar: false proto: Object
– mostafa zouhair
Nov 9 at 22:33
does the console log of the data show something? If yes then you know your request to firebase is working OK. Is the image of your console output?
– Steve
Nov 9 at 22:05
does the console log of the data show something? If yes then you know your request to firebase is working OK. Is the image of your console output?
– Steve
Nov 9 at 22:05
thanks for your reply, No the console log show me : Observable _isScalar: false, source: Observable, operator: MapOperator operator: MapOperator project: ƒ (changes) thisArg: undefined proto: Object source: Observable _isScalar: false, _subscribe: ƒ _isScalar: false proto: Object
– mostafa zouhair
Nov 9 at 22:33
thanks for your reply, No the console log show me : Observable _isScalar: false, source: Observable, operator: MapOperator operator: MapOperator project: ƒ (changes) thisArg: undefined proto: Object source: Observable _isScalar: false, _subscribe: ƒ _isScalar: false proto: Object
– mostafa zouhair
Nov 9 at 22:33
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
try this :
Patron.ts
export class PatronPage
offreList$ = ;
constructor(public navCtrl: NavController, public navParams: NavParams,
private offrep : OffreListeService)
this.offrep.getOffreList()
.snapshotChanges()
.map(
changes =>
return changes.map(c => (
key : c.payload.key,
...c.payload.val(),
));
)
.subscribe(offreList => this.offreList$ = offreList);
console.log(this.offreList$);
ionViewDidLoad()
console.log('ionViewDidLoad PatronPage');
patorn.html
<ion-item-sliding *ngIf = "offresList$.length > 0" *ngFor = "let offre of offresList$">
<ion-item >
titre : offre.titre
secteur : offre.secteur
ville : offre.key
</ion-item>
</ion-item-sliding>
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
try this :
Patron.ts
export class PatronPage
offreList$ = ;
constructor(public navCtrl: NavController, public navParams: NavParams,
private offrep : OffreListeService)
this.offrep.getOffreList()
.snapshotChanges()
.map(
changes =>
return changes.map(c => (
key : c.payload.key,
...c.payload.val(),
));
)
.subscribe(offreList => this.offreList$ = offreList);
console.log(this.offreList$);
ionViewDidLoad()
console.log('ionViewDidLoad PatronPage');
patorn.html
<ion-item-sliding *ngIf = "offresList$.length > 0" *ngFor = "let offre of offresList$">
<ion-item >
titre : offre.titre
secteur : offre.secteur
ville : offre.key
</ion-item>
</ion-item-sliding>
add a comment |
up vote
0
down vote
try this :
Patron.ts
export class PatronPage
offreList$ = ;
constructor(public navCtrl: NavController, public navParams: NavParams,
private offrep : OffreListeService)
this.offrep.getOffreList()
.snapshotChanges()
.map(
changes =>
return changes.map(c => (
key : c.payload.key,
...c.payload.val(),
));
)
.subscribe(offreList => this.offreList$ = offreList);
console.log(this.offreList$);
ionViewDidLoad()
console.log('ionViewDidLoad PatronPage');
patorn.html
<ion-item-sliding *ngIf = "offresList$.length > 0" *ngFor = "let offre of offresList$">
<ion-item >
titre : offre.titre
secteur : offre.secteur
ville : offre.key
</ion-item>
</ion-item-sliding>
add a comment |
up vote
0
down vote
up vote
0
down vote
try this :
Patron.ts
export class PatronPage
offreList$ = ;
constructor(public navCtrl: NavController, public navParams: NavParams,
private offrep : OffreListeService)
this.offrep.getOffreList()
.snapshotChanges()
.map(
changes =>
return changes.map(c => (
key : c.payload.key,
...c.payload.val(),
));
)
.subscribe(offreList => this.offreList$ = offreList);
console.log(this.offreList$);
ionViewDidLoad()
console.log('ionViewDidLoad PatronPage');
patorn.html
<ion-item-sliding *ngIf = "offresList$.length > 0" *ngFor = "let offre of offresList$">
<ion-item >
titre : offre.titre
secteur : offre.secteur
ville : offre.key
</ion-item>
</ion-item-sliding>
try this :
Patron.ts
export class PatronPage
offreList$ = ;
constructor(public navCtrl: NavController, public navParams: NavParams,
private offrep : OffreListeService)
this.offrep.getOffreList()
.snapshotChanges()
.map(
changes =>
return changes.map(c => (
key : c.payload.key,
...c.payload.val(),
));
)
.subscribe(offreList => this.offreList$ = offreList);
console.log(this.offreList$);
ionViewDidLoad()
console.log('ionViewDidLoad PatronPage');
patorn.html
<ion-item-sliding *ngIf = "offresList$.length > 0" *ngFor = "let offre of offresList$">
<ion-item >
titre : offre.titre
secteur : offre.secteur
ville : offre.key
</ion-item>
</ion-item-sliding>
answered Nov 10 at 2:35
Aïto
12
12
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53233500%2fempty-page-with-ngfor-when-i-try-to-retrive-data-from-firebase%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
does the console log of the data show something? If yes then you know your request to firebase is working OK. Is the image of your console output?
– Steve
Nov 9 at 22:05
thanks for your reply, No the console log show me : Observable _isScalar: false, source: Observable, operator: MapOperator operator: MapOperator project: ƒ (changes) thisArg: undefined proto: Object source: Observable _isScalar: false, _subscribe: ƒ _isScalar: false proto: Object
– mostafa zouhair
Nov 9 at 22:33