Render NativeStorage item on template

Hi! After a user logs in I save the user as “currentUser” in NativeStorage with no problem at all.

In another component “HomeComponent” I need to access that item and show some attribute in the template.

this.nativeStorage.getItem("currentUser").then(
      (user) => {
        console.log("currentUserrrrrr", user, 'JAPI', this);
        this.currentUser = user;
      },
      error => {
        console.log("CurrentUser", error);
      }
    );

This works fine, but when I do this in the template:

  <h1>Welcome {{currentUser.assesor.name}}</h1>

It seems to have broken the page and now I only see a white screen. I inspected it and I get this:

vendor.js:1377 ERROR TypeError: Cannot read property ‘asesor’ of null

I know that getItem is async. I’ve tried to use the " {{ expression | async }} " pipe but it also breaks.

It’s urgent. Please some one give me a clue. Thank you all in advance.

Initiate currentUser.assesor.name in the constructor with empty values

this.currentUser={ assesor:{name:‘’}}

Others will say: use ? operator, or do *ngIf. Also possible, but not the best ones

Tom

This worked perfectly! Thank you very much!

welcome. please read through the full tutorial/guides at angular.io

will be a joyfull read and veryhelpfull along the way developing