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










share|improve this question























  • 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















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










share|improve this question























  • 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













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










share|improve this question















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 firebase firebase-realtime-database ionic3 angularfire2






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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

















  • 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













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>





share|improve this answer




















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    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

























    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>





    share|improve this answer
























      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>





      share|improve this answer






















        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>





        share|improve this answer












        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>






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 10 at 2:35









        Aïto

        12




        12



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            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





















































            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