Angular + Meteor (1.3.6) helper question


#1

Hi @Urigo

Using Angular-Meteor 1.3.6:

What is the proper way of displaying a value from the user profile, let’s say a max credit number.
A server method will update this value based on user interaction.
The value is always visible in the header and needs to be reactive.

So what I have done now (and seems to work however it looked a bit buggy) is setting up a helper in the constructor:

constructor(  private $log: angular.ILogService, private $state: angular.ui.IStateService , private currentUser: any, private $reactive: any, private $scope: any ) {

    $reactive(this).attach($scope);

    this.helpers({
      user: () => {
      
        return Meteor.users.findOne({});
      }
    });
  }

Then in my template I print

{{ globalVm.user.profile.credit.used | currency: '$' : 0 }}

using my globalVm controllarAs.

In the server I update USED part of the credit in the profile based on user interaction.

The essence of what I am doing is, watching the user.profile.credit.used variable.
I already have the resolved CurrentUser object coming from UI-Router, however that one is not reactive.
So that’s why I created the helper on the (only) user in my app.
I did notice some bugginess…my subscription to invoices stopped sometimes and the USED value did not always update. Probably related to stopped subscription. Not sure…it seems to work now.

Is this the right way, or is there a better solution?


#2

@mspi can you update this topic with your solution and the new angular-meteor version?


#3

Yes, all known issues are resolved.