Fix query binding between template, view, and controller