Closed comerc closed 8 years ago
Template.test.onCreated ->
Template.currentData().b = 2
It is wrong way, because on next call of +test(a=1)
current data will be rewrited.
Workaround. I use "init" helper:
Template.test.helpers
init: ->
@.b = 2
# ...
template(name="test")
= init
// ...
https://viewmodel.org/docs/viewmodels#events
Sometimes you need to get your hands dirty and add an event listener. You can do so with the
event
property. The context (this) is the current view model.
It is solution for true 'this' inside events (and helpers).
It is simple vs
Template.instance().viewmodel.myValue()
.I propose to implement two way binding via this feature.