Preferred place to house Bindings


#1

Alright a bit of a newb question here, as I’ve seen a lot of examples of different use cases for bindings… where should we be housing our bindings?

Lately I’ve seen the view layer reduced to setting the template, and a lot of the binding logic pushed into the controller, but I’m not sure if this is a best practices decision or a use case decision.


#2

In general, explicit bindings in JavaScript rarely appear as more and more of the responsibility of keeping values in sync has been pushed to templates. I rarely explicitly set up bindings in my applications anymore.

If I were you, I wouldn’t feel any pressure to try to put more bindings in your app.


#3

In a case where I’d want to compare the current user to the logged in user, there’s no way to avoid putting this in the controller though right? or would you find some way to put that into the templates as well?


#4

Alright months later, but I’m not sure I totally understand:

Even if I declare the bindings within the templates themselves, where would I calculate (for instance) a style property?

It seems inappropriate to house this in the controller, and at the same time the logic can’t live in the template.

So my gut tells me between Controller, View, and Template, this should live in the View code.

…Or is the overall trajectory to sunset Views entirely in favor of Templates?