2

I am trying to add the user's info to my side menu from '../providers/data'

This the page app.html

<ion-menu side="right" [content]="content">
<ion-content class="no-scroll">
 <div class="menu-bg-color" >
        <ion-list no-lines >
            <div *ngIf="user">
            <ion-item class="menu-top">
                <img src="{{user.img}}" width="80" height="80">
                <div class="divider"></div>
                <h2>{{user.name}}</h2>
                <p>{{user.email}}</p>
            </ion-item>
            </div>
            <div class="divider-long"></div>
            <ion-item item-left class="ions-item" *ngFor="let p of pages" (click)="openPage(p)">
               <ion-icon class="icon-style"  name="{{p.icon}}" item-left></ion-icon>
                <h3 class="text-menu">{{p.title}}</h3>
            </ion-item>
        </ion-list>
</div>
</ion-content>
</ion-menu>
<!--What's my root? remember the this.rootPage?-->
<ion-nav id="nav" [root]="rootPage" #content swipe-back-enabled="true"></ion-nav>

i can import the user's info to the other pages with this function:

ionViewDidLoad() {
    this.loadingProvider.show();
    this.dataProvider.getCurrentUser().subscribe((user) => {
      this.loadingProvider.hide();
      this.user = user;
      console.log("page profile : " + user.name)
    });
  }

The question is: how can i import the user's info to the page app.html(side menu page)

0

1 Answer 1

0

You can use:

ngOnInit(){
this.loadingProvider.show();
this.dataProvider.getCurrentUser().subscribe((user) => {
  this.loadingProvider.hide();
  this.user = user;
  console.log("page profile : " + user.name)
});
}
4
  • Thanks, but i got this error: Runtime Error Cannot read property 'parentElement' of undefined
    – Fray
    Feb 12, 2017 at 19:04
  • The error is not from ngOnInit. test the method with just a console log. Feb 12, 2017 at 19:20
  • The problem is the loading of user's info. I think the side menu will be created before the importation of data from dataprovider
    – Fray
    Feb 13, 2017 at 17:20
  • You can move side menu to another component. Feb 13, 2017 at 17:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.