Closed avalanche1 closed 8 years ago
That's because you're invoking the method when the app is loaded. Don't use the parentheses for userId (haven't tried it but it should work) On Mar 2, 2016 7:13 AM, "Artem Saffron" notifications@github.com wrote:
Template.name.viewmodel({property:Meteor.userId()}) returns undefined. Even if I call this from console after template is fully rendered.
— Reply to this email directly or view it on GitHub https://github.com/ManuelDeLeon/viewmodel/issues/196.
No, I have this template appear only after I click a button - my app is already fully loaded by that time.
And how can I not user parentheses? Meteor.userId
is a function, is it not?
Yes it's a function but you're invoking the function when Meteor loads the app, not when the template is instantiated. Replace Meteor userId with console log to see what I mean. On Mar 3, 2016 2:33 AM, "Artem Saffron" notifications@github.com wrote:
No, I have this template appear only after I click a button - my app is already fully loaded by that time. And how can I not user parentheses? Meteor.userId is a function, is it not?
— Reply to this email directly or view it on GitHub https://github.com/ManuelDeLeon/viewmodel/issues/196#issuecomment-191677983 .
Ok, I've fixed it with
Template.name.viewmodel({
load:{
property: Meteor.userId()
}
})
But is there a way to do it without load
??
Use a function that returns the userId On Mar 3, 2016 6:37 AM, "Artem Saffron" notifications@github.com wrote:
Ok, I've fixed it with
Template.name.viewmodel({ load:{ property: Meteor.userId() } })
But is there a way to do it without load??
— Reply to this email directly or view it on GitHub https://github.com/ManuelDeLeon/viewmodel/issues/196#issuecomment-191763389 .
btw, if all you're doing is returning the userId then it's better to put it in a mixin so you can use it on other templates.
Template.name.viewmodel({property:Meteor.userId()})
returns undefined. Even if I re-run this from console after template is fully rendered.