Open cafe4it opened 7 years ago
This is indeed not working at all. If you try to do this:
Template.example2.viewmodel({
share: 'clock'
onCreated: function() {
console.log(this.clock);
}
});
it will throw an error saying _this.clock is not a function
@satyavh your code is incorrect, you should re-read the documentation of ViewModel.
share: 'clock'
specifies which ViewModel Share you want to use in that vm. It's not a property in itself.
So instead, you should have something like this:
Template.example2.viewmodel({
share: 'clock'
onCreated: function() {
console.log(this.initialTime());
}
});
@cafe4it I wrote a repro with basically your code and all seems fine and working. What's the actual issue you are having?
Hi, i try functions onCreated, autorun but not working