Following the documentation, I am able to display the person object in the sayHelloView. Now I am wondering how I can trigger the else condition to see the bindings in action. Is there a way to do delete the person using the browser console or am I barking up the wrong tree?
JsFiddle – http://jsfiddle.net/PhSRx/
You could have an action which sets the view’s person to null.
So in your view template you’d have something like:
When that’s clicked, it will trigger the
logoutmethod for the view and then you can setthis.personto null:I’ve forked your fiddle and updated it, also adding in a login action which sets the person so you can toggle between and see the bindings in action: http://jsfiddle.net/rlivsey/atzfx/
Instead of the view handling logging in and out, you might want to delegate that out to a controller.
Here’s a fiddle with an example of
App.sessionControllerdealing with holding onto the current logged in person, and the view has a binding to the person so the template stays the same even though the architecture has changed – http://jsfiddle.net/rlivsey/QKa3N/